Generally Useful Commands

Help Center > Introduction to Unix > Generally Useful Commands

ps (Process Status)

The ps command provides a list of processes that you are currently running on the machine. The list shows the information for each process in four categories:

  • Process ID (PID) - a unique number assigned to the process.
  • Terminal line (TTY) - the terminal number that the process was started from.
  • Run time (TIME) - how much computer time the process has used.
  • Command (CMD) - the command that is being processed.

Here's an example of the output for ps, showing only the shell being used and ps itself being processed at that moment in time.

% ps
PID TTY TIME CMD
120380 pts/2 0:00 -tcsh
124184 pts/2 0:00 ps

The ps aux command displays a list of all processes being run by all users on the machine. Here's an example of the command's output:

% ps aux
USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND
root 516 93.4 2.0 8 5592 - A Oct 03 439631:53 kproc
root 2154 1.2 0.0 44 36 - A Oct 03 5617:16 /usr/sbin/syncd
root 48894 0.5 1.0 1552 1468 - A 14:30:26 0:06 /usr/local/sbin/
jkoenig 50914 0.5 3.0 5648 6804 pts/21 A 14:13:21 0:10 pine4.44
root 33862 0.3 1.0 2528 2152 - A 07:57:57 1:24 /usr/local/sbin/
beresfrd 97890 0.3 4.0 7364 8520 pts/12 A 13:17:58 0:16 pine4.44
root 39186 0.2 0.0 728 792 - A 13:41:14 0:10 telnetd
sethsch 91384 0.0 0.0 892 988 pts/10 A 08:09:16 0:01 -tcsh

kill (Terminate a Process)

One of the most useful commands to know when you are running your own Unix machine is kill. This command terminates a process, given that you know that process's PID. Enter the command followed by the PID of the process you want to kill (generally, you find the PID in your ps output). kill has varying degrees of intensity, depending on how hard it is to get rid of a process. The intensity rating ranges from 1 to 9, with 9 being the strongest. So if you really wanted to kill a pesky process that won't go away, you would enter something like this at the command line:

% kill -9 91384

find (Search For Files)

Another useful command is find, which searches for files. find can be complex, but a simple ways to search is shown in the example below.

% find . -name '*.txt' -print
This will find and output the location of all of the files with '.txt' in their name that are in the current directory and all of its subdirectories. (For more information on find, look at its man page.)

A more intuitive search command is locate, which is unfortunately not available on the UA clusters. You would, however, most likely find it on your personal Linux distribution. Follow the locate command with the name or partial name of files you are looking for:

% locate password
/etc/password
/usr/local/mystuff/mypasswords
last modified on 01/29/2008 12:03