Previous Table of Contents Next


The command interpreter for UNIX is ksh (csh - BSD). The shell reads input from your terminal, interprets what you typed, and attempts to execute a program based on the input. A command is the name of a program or utility followed by options and arguments used by the program. To execute a program, the shell searches for the program based on the directory paths set in the PATH variable. The following activities will clarify command execution.

1.  Display the PATH variable by typing echo $PATH and pressing Return. Notice the ":" separated fields; the ":" separates directory paths the shell searches for commands. The "." represents the "Present Working Directory."
   cj> echo $PATH
2.  Display who is on the system by typing who and pressing Return. Notice a table of information is displayed. The leftmost column is the user name followed by the port address, and time of login. The shell searched the path and found the who command in the /bin directory.
3.  Type xprogx and press Return. Notice that the system responds by displaying:
   cj> xprogx
   ksh: xprogx: not found

This tells you that your ksh could not locate the xprogx program within the directories defined in PATH.


There are times when you decide to abort a program before it has completed execution. On UNIX you send an INTERRUPT signal to the program. To send the INTERRUPT signal, press the Delete key. The csh uses the Ctrl-C key sequence to abort an executing program. Some system administrators change the default abort or interrupt character to Ctrl-C instead of Delete or vice versa.

To display what your INTERRUPT signal is defined as, type stty (stty everything on BSD) and press Return. Look for the "intr = XX" field. The XX is the defined key. The "^?" sequence refers to the Delete key (octal 177).


In this section you use the "everyday commands" of UNIX. There are commands to display, create, copy, rename, move, delete, and list files and directories. There are commands to count words, select strings, sort, print, and compare files. There are also procedures on redirecting output and using the powerful UNIX pipe commands. Begin this section at your shell prompt.


UNIX provides two popular ways to list files.

1.  Type ls -la and press Return. Notice that the first two lines begin with "d" and end with ".". The "d"s represent directories. The "." represents your current directory. The ".." is your parent directory.
2.  Type find . -type f -print and press Return. This will display all files in you current directory and all subdirectories.


The following commands display the contents of ASCII files to the standard output.

1.  Display the contents of a file by typing cat /etc/passwd and pressing Return. Notice the system's password file is displayed on your terminal.
2.  Display /etc/passwd one page at a time by typing pg /etc/passwd and pressing Return. pg is useful for files that are longer than one terminal screen. Notice that the first 23 lines are displayed and a : is displayed in the bottom left corner of your screen. To continue to the next page of text press Return or, for help, type ? and press Return.

BSD (Berkeley)
On BSD you use the more command instead of pg.

If the file pg reads less than 23 lines, then pg will not prompt for further input from your terminal. It basically acts like the cat command on short files.

3.  Display the first 5 lines of the /etc/passwd file by typing head -5 /etc/passwd and pressing Return. Notice only the first 5 lines of the file are displayed on your terminal. Some systems do not support the head command.
4.  Display the last 5 lines of the /etc/passwd file by typing tail -5 /etc/passwd and pressing Return. Notice only the last 5 lines of the file are displayed on your terminal.
5.  Format the file into pages by typing pr /etc/passwd and pressing Return. Notice the file is preceded by a one-line header and has a page header every 60 lines.


The following commands show different methods of creating files and directories.

Previous Table of Contents Next