Unix commands are instructions that we use to tell Unix what we want it to do. On the undergraduate machines at UBC, we can pass a command to Unix through a terminal window called xterm. This window is created automatically when we log in, but we can also create an xterm by pressing the button called "Shell" located at the bottom right corner of the desktop. Basically, we interact with Unix through the following steps:

A shell is a command interpreter that processes, among others, the commands we type into a terminal window (the xterm). Three common Unix shells are the Bourne shell (sh), the Korn shell (ksh), and the C shell (csh). All three shells share a common set of operations and rely on the same concepts, but each also has its own features. On the undergraduate Unix machines at UBC, the default shell is csh. It is automatically invoked when a user logs in to an undergraduate terminal. Because you will be working with csh most of the time (and despite its design flaws), these notes will almost exclusively be based on the C shell. The Bourne shell is also commonly available, and is in fact the preferred shell when one is writing a program to be interpreted by the shell (a shell script). It is discussed in detail in the sections under the "Additional Material" heading.

The xterm window looks like:

The prompt shows that the shell is ready to accept a command. It is where we type the Unix commands that we want the shell to interpret. In the following sections, a percent sign % is used to represent this xterm prompt. We do not type % as part of our Unix commands.

Command Form

A Unix command generally takes the form:

commandname [options] [arguments]

where commandname is a Unix command or the name of a program or application, options is an optional list of options that modify the behavior of the command, and arguments is an optional list of arguments that the command acts upon. The shell begins interpreting the command after we press the [Return] key.

Let us type a command into the xterm window. Suppose that we type the following into our xterm window:

% ps[Return]

ps is a Unix command that lists the programs that are currently running on our system. We will learn more about this command later.

Now the xterm window will look something like:

The xterm displays the output on the line following the ps command. In this example, the programs currently running are csh and a graphic capturing program called xv. After the output is displayed, the shell is back to its ready mode, as shown by the prompt in the xterm window.