Search A-Z index Help
University of Cambridge Home Physics Dept Home Mike Roses' Home Page TCM Group Home

Unix 101: Finding and Changing the Shell

What shell am I using and how do I change it? New Unix users commonly ask these questions. In this article, you will learn how to determine the current shell and change it.

What Shell Am I Using?

The Unix shell interprets commands and interacts with the base Unix system (called the kernel). For example, when you type

rm *.bak

at the Unix prompt, the shell finds all files whose filenames end with .bak and asks the kernel to remove them.

There are several different Unix shells. To determine which shell you are using type

ps

at the Unix prompt. This will provide a list of processes. A process is a Unix command or program that you are currently running. The shell is a process so you will see the executable name of your shell in the process list. Depending on your system, it may be listed several times. Below is a table of common Unix shells and their executable names.

Shell Executable Name
Bourne Shell sh
Restricted Bourne Shell rsh
Korn Shell ksh
Bash Shell bash
Z-Shell zsh
C-Shell csh
TC-Shell tcsh

For example, using ps on my system

> ps
  PID  TT  STAT      TIME COMMAND
  248  p0  Ss     0:00.10 -tcsh (tcsh)
  256  p0  R+     0:00.00 ps

displays the tcsh process indicating that I am using the tc-shell.

The Korn, z-shell and bash shells are all derivatives of the Bourne shell. They support most or all of the Bourne shell features plus additional advanced features. Likewise the tc-shell is a derivative of the c-shell. Many examples are specific to either the Bourne shell and its derivatives or the c-shell and its derivatives.

Site Conventions - Shells

In most Focus on Unix examples, Unix commands are shown preceded by the Unix prompt. For example,

$ ls

The dollar sign ($) is the prompt. It indicates the beginning of a Unix command and should not be typed. Most examples will work in any shell. In this case, the shell prompt is generically indicated by a $ (dollar sign). You will always be told when an example is shell specific. In these special cases:

  • The shell prompt for the Bourne shell and its derivatives (sh, ksh, zsh, bash) is indicated by a $ (dollar sign).
  • The shell prompt for the c-shell and its derivatives (csh, tcsh) is indicated by a % (percent sign).

What Shells are Available?

Most Unix systems have more than one shell available. The file /etc/shells contains a list of all shells available on the current system. For example,

$ cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/bash2
/bin/ash
/bin/bsh
/bin/tcsh
/bin/csh

Temporarily Changing the Shell

To temporarily change shells just type the executable name of the new shell at the Unix prompt. For example, if you are a Korn shell user who wants to try the c-shell,

$ csh
%

will start a c-shell session.

When you are done, type exit to return to the previous shell. For example, to exit the c-shell and return to the Korn shell,

% exit
$

Permanently Changing the Shell

Methods for permanently changing the shell vary from system to system. The first step is to determine the full path to the new shell. The path is shown in the /etc/shells file. In the above example, the full path to the c-shell is /bin/csh and the full path to the bash shell is /usr/local/bash.

Once you have determined the full path to the new shell, the chsh, chpasswd, passwd, ypchsh or ypchpasswd command are normally used to change the default shell. Try reading your system manual page for these commands. For example,

$ man chsh

WARNING: Be careful changing your default shell. It is possible to make a mistake that only your system administrator can fix. Make sure you are changing to valid system shell and that you have tried temporarily using the shell first.

Related Links