13.2. Information on processes: ps and pstree

These two commands display a list of processes present on the system according to criteria set by you.

13.2.1. ps

Sending this command without an argument will show only processes initiated by you and attached to the terminal you are using:

$ ps 
  PID TTY          TIME CMD 
 5162 ttya1    00:00:00 zsh 
 7452 ttya1    00:00:00 ps

There are a large number of options, of which we will look at the most common:

There are many other options. Refer to the manual page for more information (man 1 ps).

The output of this command is divided into different fields: the one that will interest you the most is the field PID, which contains the process identifier. The field CMD contains the name of the command executed.

A very common way of calling up ps is as follows:

$ ps ax | less 

This gets you a list of all processes currently running, so that you can identify one or more processes which are causing problems and subsequently kill them.

13.2.2. pstree

The command pstree displays the processes in the form of a tree structure. One advantage is that you can immediately see what is the parent process of what: when you want to kill a whole series of processes and if they are all parents and children, you simply kill the parent. You want to use the option -p, which displays the PID of each process, and the option -u which displays the name of the user who started off the process. As the tree structure is generally long, you want to call up pstree in the following way:

$ pstree -up | less 

This gives you an overview of the whole process tree structure.


Tux on Star from MandrakeSoft Linux is a registered trademark of Linus Torvalds. All other trademarks and copyrights are the property of their respective owners.
Unless otherwise stated, all the content of these pages and all images are Copyright MandrakeSoft S.A. and MandrakeSoft Inc. 2000.
http://www.linux-mandrake.com/