Understanding shells

You can use a shell to work interactively with your computer, customize your work session, and create programs called shell scripts. Common UNIX shells include the Bourne shell, Korn shell, and C shell.

Typically in UNIX, the shell is invoked when you log on. The shell gives you a prompt, such as a dollar sign ($) in the Korn shell, or percent symbol (%) in the C shell. You type commands at this prompt to communicate interactively with the operating system. For example, if you wanted to list file names, you would type the ls(1) command, which is used to list file names. The shell would search for an executable file with the same name as the command, start the executable file as a new process in memory, and return output from the process to the screen. The shell searches only within the directories specified in the Interix subsystem PATH environment variable.

The shell also contains variables that control the behavior of your work session. Your system automatically sets values to many of these variables. You can also define certain variables, either through the command prompt or through special start-up files that run automatically when you log on. For example, .profile is a Korn shell startup file and .cshrc is a C shell startup file.

You can also use UNIX shells to execute a sequence of commands through the use of shell scripts. A shell script is a special program, stored as text, that contains the same commands you type at the command prompt. It also contains special scripting commands that can rival the power of commands used in programming languages such as C.