Shell Processes   «Prev  Next»
Lesson 4 Starting other shells
Objective Starting interactive shell at the command line.

Starting other Shells in Unix

Starting an interactive shell from the command line in Unix involves running the appropriate shell command. An interactive shell reads commands from user input on a terminal, which distinguishes it from a non-interactive shell executing a script.
Here are the steps to start an interactive shell:
  1. Open Terminal: In Unix, you can typically open the terminal from your Applications menu or via a shortcut, which often involves the Ctrl + Alt + T keys.
  2. Run the Shell Command: After opening the terminal, you'll be in your default shell. To start a new interactive shell session, you enter the command for the shell you wish to use. The table below lists commands for some common shells:
    For example, if you want to start a new interactive Bash shell, you would enter the command bash.
    After running the command, the new interactive shell session will start. The command prompt will reflect the shell change, though the specific appearance can depend on your system configuration.
  3. Exit the Shell: To exit the shell and return to your default shell, you can use the exit command or the Ctrl + D keyboard shortcut.

Remember, these shell sessions are child processes of your original shell and will not affect your default shell. Any changes you make to the environment, such as setting environment variables, will only persist within that shell session. Once you exit the shell session, you'll return to your original shell environment.
Note: If the desired shell isn't installed on your system, you may need to install it first. Installation procedures vary depending on the shell and the specific Unix system you are using.
If you wish to run a new shell, type in the program that runs that shell at the command line.
The three primary UNIX shells are listed in the chart below along with the command that runs that shell.
Program Shell Comment/bin/sh Bourne A subset of Korn
/bin/ksh Korn A superset of Bourne
/bin/csh C Not compatible with Korn or Bourne

Review of the three primary UNIX Shells

  1. Bourne shell
  2. Korn shell
  3. C shell

Bourne shell

The Bourne shell was written before the other two primary shells. It has the smallest number of features of any of the shells, but is commonly used to write shell scripts. Bourne shell scripts can be run from either the Bourne or Korn shells because Korn is backwards compatible with Bourne.

Korn shell

The Korn shell was written last of the three primary shells. It is the Bourne shell plus some additional programming features.
The Korn shell was developed at AT&T's Bell labs.

C shell

  1. The C shell was written after the Bourne shell and is not compatible with the other two shells.
  2. The C shell was written at UC BerkeleyThe C shell (csh or the improved version, tcsh, on most machines) is a Unix shell that was created by Bill Joy while a graduate student at University of California, Berkeley in the late 1970s.
  3. It has been distributed widely, beginning with the 2BSD release of the BSD Unix system that Joy began distributing in 1978.
  4. The C shell is a command processor typically run in a text window, allowing the user to type commands.
  5. Like all Unix shells, C shell supports filename wildcarding, piping, command substitution, variables and control structures for condition-testing and iteration.

What differentiated the C shell from others, especially in the 1980s, were its interactive features and overall style. Its new features made it easier and faster to use. The overall style of the language looked more like C and was seen as more readable. On many systems, such as Mac OS X and Red Hat Linux, csh is actually tcsh, an improved version of csh.

Other popular shells

Foreground and background shells

When you first login, you are interacting with your login shell. This shell is said to be running in the foreground since you can interact with it. When you run a new shell, your original shell is put into the background and your new shell is run in the foreground. Being in the background means that your shell is waiting, ready to run, in the memory of the computer, but that you cannot interact with it. When you exit the new shell, your original shell will be brought back into the foreground automatically and you can interact with it again.
The SlideShow below shows you how to start a new shell on the command line to run the ps command to look at which processes are running as you start new shells. The SlideShow will point out which shells are in the foreground and background as you go through these commands.

Unix Shells 1
1) Unix Shells 1

Unix Shells 2
2) Unix Shells 2

Unix Shells 3
3) Unix Shells 3

Unix Shells 4
4) Unix Shells 4

Unix Shells 5
5) Unix Shells 5

Unix Shells 6
6) Unix Shells 6

Unix Shells 7
7) Unix Shells 7

Unix Shells 8
8) Unix Shells 8

Starting Shells - Exercise

Click the exercise link below to practice running other shells from the command line.
Starting Shells - Exercise
The next lesson looks at the relationship between parent and child processes.

SEMrush Software4