UNIX Shells

The following table briefly describes the shells available on LC systems. You might want to print a "cheat sheet" that lists useful shell commands and shortcuts [PDF].

csh

The C shell. This shell uses a command structure and syntax similar to the C programming language.

On Linux, the csh is a link to tcsh.

A system cshrc is executed, followed by the following files located in your home directory (in order of their execution). You may override settings in the system chsrc from within your .cshrc and .login.

.cshrc
.login (executed only at login)
.logout (executed only at logout)

sh

This shell is implemented in a variety of ways. It is either the POSIX shell (a "standard"), the Korn shell, or the Bourne shell. sh is historically known as the Bourne shell, but when the POSIX standard was developed, some vendors switched sh to be the POSIX shell, also referred to as the Korn shell. Note that on some machines both the POSIX and Bourne shell are available, both known as "sh."

On the IBMs, sh is equivalent to ksh and is backward compatible with the Bourne shell.

On the Compaqs, a version of sh exists for both the POSIX shell (/usr/bin/posix/sh) and the Bourne shell (/usr/bin/sh).

On the Suns (SunOS), /bin/sh is the Bourne shell and /usr/xpg4/bin/sh is the Korn shell. The Korn shell is the POSIX shell.

On Linux, sh is a link to bash.

At login, a system profile is executed. You may override settings in the system profile from within your .profile. Next, the .profile file, located in your home directory, is executed.

ksh

The Korn shell. On some machines the Korn shell is backward compatible with the Bourne shell. On some machines the Korn shell and the POSIX shell are the same shell; see the sh description above for more details.

At login, a system profile is executed. You may override settings in the system profile from within your .profile. Next, the .profile file, located in your home directory, is executed.

An additional system profile is also executed, prior to your .profile. You may override settings in the system profile from within your .profile.

tcsh

The tcsh, sometimes referred to as the "T C Shell" is the C shell with file name completion and command line editing (though many implementations of the C shell offer these features) and more. Tcsh is compatible with the Berkeley Unix C shell.

At login, a system cshrc and login file are executed, followed by execution of the following files (in the order they are executed) located in your home directory:

.tcshrc, if found, otherwise .cshrc
.history (or the value of the histfile shell variable)
.login
.cshdirs (or the value of the dirsfile shell variable)

The shell may read the system login before (instead of after) the system cshrc, and your ~/.login before (instead of after) your ~/.tcshrc or your ~/.cshrc and ~/.history, if so compiled; see the version shell variable for details.

The tsh command is a command interpreter that provides greater security than the Korn shell (the standard login shell). Generally, a user calls the tsh shell by pressing Ctrl-X, Ctrl-R, the secure attention key (SAK) sequence, after a login. The tsh shell also can be invoked by defining it as the login shell in the /etc/passwd file.

bash

The GNU Bourne-Again shell is an sh-compatible shell. Bash also incorporates useful features from the Korn and C shells (ksh and csh). Bash is ultimately intended to be a conformant implementation of the IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2).

On Linux, bash is the default shell. To force POSIX compliance, add the --posix command-line option.

When bash is invoked as a login shell, it first reads and executes commands from the system profile file, then it looks for the following files in your home directory, and executes the first one it comes to:

.bash_profile
.bash_login
.profile

When bash is started non-interactively, to run a shell script for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute.

When bash is started in POSIX mode, as with the --posix command-line option, it follows the POSIX standard for startup files. In this mode, the ENV variable is expanded and commands are read and executed from the file whose name is the expanded value. No other startup files are read. This is done by interactive shells only.

The .bash_logout is executed during logout, if it exists.

bsh

The Bourne shell (IBM's AIX implementation).

zsh

The Z shell, zsh, is a shell designed for interactive use, although it is also a powerful scripting language. Of the standard shells, zsh most closely resembles ksh but includes many enhancements of many types, notably in the command-line editor, options for customizing its behavior, file name globbing, features to make C-shell (csh) users feel more at home, and extra features drawn from tcsh.

There are five startup files from which zsh will read commands:

$ZDOTDIR/.zshenv
$ZDOTDIR/.zprofile
$ZDOTDIR/.zshrc
$ZDOTDIR/.zlogin
$ZDOTDIR/.zlogout

Top