A Unix Command Summary

This is a short and simple summary of frequent commands that you need to know in order to use a unix machine. Most of these commands are applicable to any unix machine, however, some may be machine and/or operating system specific (these are marked appropriately). We first talk about unix shells and then go on to the commands.

Unix Shells

A Unix shell is an interactive command interpreter which is what accepts the commands that you type, and runs the appropriate program to process them. There are a number of popular shells in unix systems, including the "C" shell variants (csh, tcsh), korn shell variants (ksh, zsh) and bourne shell variants (sh, bash). The first in each of the variants is the original shell, and the second one is the recent improved version. Most shells have similar look and feel, but the newer ones (tcsh, zsh, bash) have advanced features such as command and file completion, command-line editing etc. You can change a shell by running the "chsh" (change shell) command.

This information is CS Burrow cluster specific. To change your shell, you will need to log in to paca, the NFS server for the Burrows. Once you log in, type the command which <shell name> (replace <shell name> with the shell you choose). This will tell you where the shell is located (e.g., csh is located in /usr/local/bin/csh). Next, type chsh, enter the new shell when prompted, and you are done. Note that you will have to log out of paca, and log back in to one of the burrows machines when you are done. It takes around 5 minutes or so for the shell changes to propagate to all the machines.

Every shell has its own settings file in which you can spedify special configuration options. See the manual page for your shell to get the details of the syntax and format of this file.

Unix Paths

Most Unix commands are actually programs that run when you type in the command. Some commands are built-in to the shell that you use. When you type in a command, the shell looks for this command in a list of directories that you specify. This list of directories is the "path". Depending on the shell you are using, the syntax for declaring the path will be different, but the usual set of directories to include in the path are (some of these paths are IU Burrows cluster specific):

.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/etc:/sbin:/usr/sbin:/usr/ccs/bin:/usr/dt/bin:/usr/local/gnu/bin

Keep in mind that the longer the path is, the longer it takes the shell to search through all the commands in the path. You might want to look at these directories to see if there are commands in there that you do use. If not, you may want to remove the paths. Some shells create an index structure of all the commands when they start up, which reduces this searching time.

Also, having the "." in your path allows you to run your scripts and programs from the current direcory without having to type "./" in front of the script or program name.

Commonly used Unix Commands

Here is a list of commonly used unix commands in alpahbetical order. Each command includes a description and typical invocations. Note that almost all the unix commands accept command line arguments and options that usually start with a dash (-). The options can be stacked (i.e., if a command accepts options -a and -b, it will also accept -ab).

cat
Similar to the DOS type command, it dumps the contnet of files (specified in the command line) in the standard output.
chmod
chmod is the unix command to set and change the permission modes for files and directories. There are two main ways to invoke chmod:
cp
This is the unix file copy command. Typical invocation is cp file1 file2. The -r option can be used to copy recursively.
date
Prints out the current date and time. The -u option can be used to print Universal (GMT) time.
diff
Displays the differences between two text files. The -c option can be used to show some "context".
du
Displays the current disk usage, recursively for every subdirectory of the current directory. The -s option can be used to display only the total usage, without any breakdown.
find
A very powerful file finder. The simplest invocation is: find . -name "filename_with_wildcards" -print. See the manpage for further options.
grep
Search for strings in one or more files. Typical invocation is: grep "string" filenames.
gzip
gzip is one of the most popular compression tools in unix. Faster, more compression capabilities, and cheaper (free!) than the standard "compress" command. Invocations:
kill
Kills (sends signals to) process. The simplest invocation is kill -[SIGNAL] pid_list where SIGNAL can be any valid unix signal (e.g., HUP, TERM, STOP, CONT) and pid_list is a list of process IDs (can be looked up by the ps command).
ls
This is the command to display the list of files and directories in the current directory or a directory specified in the command line. Commonly used options include -l for detailed listing, -a to display hidden files (files starting with a .), -t to display files sorted by the modification time, etc.
lynx
lynx is a text-based WWW browser for unix. In lynx, the tab key and the up and down arrows are used for moving around in a displayed document. The left and right arrows are used for following links and going back to the previously displayed document. It can be invoked without any arguments or by specifying an URL in the command line.
mkdir
Creates a directory. Simplest invocation is mkdir directoryname
mv
Moves a file or directory to another name. Directories can not be moved across different partitions.
ps
ps is the unix command for displaying currently running processes. The behavior of ps is not consistent across different variations of this command. The gnu ps implementation differs significantly from the common ps. See the manual pages for further details.
pwd
Prints the current working directory.
rm
The unix file remove command. Can be used with the -r option to recursively remove everything (use with caution). The -i option can be used to turn on "interactive" mode - rm will ask for every file whether or not you want it to be removed.
rmdir
Removes a directory, only if the directory is empty. To remove non-empty directories, use rm -r
tar
Tar (Tape ARchive) is the unix format for archiving multiple files, both ascii and binary, in tapes for backing up purposes. Although originally designed for tape archiving, it is commonly used for archiving files into a single big file. The same command is used for archiving and extracting from the archives. Typical invocations are:
top
top is a process that displays the processes running on the system, sorted by CPU usage. The display typically updates itself every few seconds. Very useful to check if any of your programs are running out of control.
which
See where a particular executable is located. Useful to find out whether you are actually running the right program. (e.g., which httpd will tell you which httpd you will run if you just typed httpd at the prompt).
who
Displays all the people who are logged on or have processes running on the system.

Last modified: Sun Sep 28 22:52:02 EST 1997 asengupt@cs.indiana.edu