How does the Unix shell interpret what you type?

Last revision August 6, 2004

Table of Contents:
  1. Shell interpretation
  2. Editing command lines
  3. Stuck in a Unix login session?
  4. Program execution
  5. Simple commands
  6. Unix command syntax
  7. Controlling processes
  8. Your login environment

The shell uses a prompt to let you know that it is ready to accept commands. The standard Unix prompt is a percent sign (%). On pangea, we have changed this to be pangea>. You can set your own prompt, which will be described in the section on controlling your shell environment.

Case is important. Uppercase A and lowercase a are not the same. Unix is strongly oriented to lower case letters. In general, everything is in lower case, unless the documentation specifically says to use upper case, for example, for certain command options.

Everything between blanks (spaces) or tabs, unless quoted, is considered to be a separate word or token. Pressing the RETURN key signals the shell to start interpreting the line. You can keep typing a long command past the end of the screen and it will wrap around. Just do not press the RETURN key until you have typed the complete command.

The first word typed on a line is generally interpreted as the name of a program to run. The shell looks in a set of pre-defined directories (which you can alter) to find an executable file of the same name and then starts a process to execute that program. Remaining ordinary words or tokens on the line are interpreted as an argument list of information to be passed along to the program. This list describes the files to be affected or the options to be used.

Some words that you type are reserved keywords that are interpreted as commands directly to the shell to change some attribute of its own process, not as programs to be run. An example is the cd command, which changes the current working directory of the shell process.

Finally, many non-alphanumeric characters that can be included in command lines have special meanings to the shell. They tell it how to set up the environment of the program you wish to run or how to combine processes, etc. This is one of the most powerful and most frustrating features of Unix. You try to use a non-alphanumeric character as an argument to a command or in a filename and something very strange happens because the shell interprets that character specially.

A general rule for beginners is to avoid using non-alphanumeric characters (except for dot and underscore), for example, as part of a filename. Only use them where they are specifically called for as part of the command syntax. If you have to use them, escape them by preceding with a backslash (\) character, or enclose the entire word or string of words containing the special character in single quote (') characters.

There is a complete list of all characters that have special meanings to the C-shell, which is the most common command-line shell.

  Overview Next-->

Comments or Questions?