Department of Computing Imperial College
Process management

Linux is a multi-tasking, multi-user operating system. This means that lots of people can run lots of tasks (processes) on the same machine, at the same time. Problems can arise if processes are very computationally intensive, and hog the Central Processing Unit (CPU). If this happens, the CPU will be constantly busy, and the system will slow down. Luckily, most tasks tend to spend a lot of time waiting for other information, so this situation does not arise that often.

You should know which processes you are running, the load that these processes are placing on the system, how they can indirectly effect other users, and how to stop these processes.

The ps command shows you the processes you are running:

sync01% ps x
  PID TTY STAT TIME COMMAND
12492  pb S    0:00 -tcsh 
12559  pb R    0:00 ps x 
In this case the user has only just logged in therefore the only processes running are the login shell (tcsh) and the command ps itself.

If we modify the ps command it will show us not just our own processes, but all processes run by all users including the system itself (processes owned by 'root' or the system administrator):

sync01% ps aux | more
USER       PID %CPU %MEM  SIZE   RSS TTY STAT START   TIME COMMAND
ard      12492  0.0  0.8  1748  1072  pb S    14:58   0:00 -tcsh 
bin        287  0.0  0.2   780   356  ?  S    18:33   0:00 portmap 
cc5      11918  7.3 15.0 23776 19268  pa S    14:14   4:07 /usr/lib/netscape/net
cc5      11928  0.0  2.0 12876  2636  pa S    14:14   0:00 (dns helper) 
daemon     265  0.0  0.3   800   444  ?  S    18:33   0:00 /usr/sbin/atd 
ikz      11510  0.0  0.9  1800  1168  p8 S    13:51   0:00 -tcsh 
jmh2     11155 74.0 14.4 24752 18500  ?  R    13:25  78:08 /usr/lib/netscape/net
jmh2     11165  0.0  2.0 12876  2632  ?  S    13:25   0:00 (dns helper) 
nu98      9476  0.0  0.9  1860  1224  p3 S    12:17   0:00 -csh 
nu98     10272  0.0  1.1  2176  1464  p4 T    12:51   0:00 perl timetable3.pl 
nu98     10454  0.0  0.7  1480   916  p3 S    12:58   0:00 vi timetable.pl 
root         1  0.0  0.3   796   436  ?  S    18:33   0:03 init [5] 
root         2  0.0  0.0     0     0  ?  SW   18:33   0:00 (kflushd)
root         3  0.0  0.0     0     0  ?  SW<  18:33   0:00 (kswapd)
root         4  0.0  0.0     0     0  ?  SW   18:33   0:00 (nfsiod)
Note that this can be quite a long list and we have abbreviated it here. The output is 'piped' to the command 'more' to show it one screenful at a time - hit the space bar to continue.

See the Linux manual page on the ps command for more information on what the columns mean:

man ps
To terminate a process you have started, type:
kill -9 pid
where 'pid' is the number listed in the PID column. The -9 flag ensures that any protections the process may have are overridden by this command.

Considerate use of system resources

It is very easy under Linux for an individual to seriously affect the performance of a the service. Users should therefore be aware of the consequences of the commands that they are running.

Process Management Commands

This is a list of commands which can be used to control processes.

General commands

kill
Send a signal to a process, or terminate a process.
ps
Display the status of current processes.
nice
Run a command at low priority.
top
Display and update information about the top cpu processes.
nohup
Run a command immune to hangups and quits.
sleep
Suspend execution for an interval.

C Shell Related Process Management Commands

<command> &
Place the command in the background.
Control-Z
Suspend the Current Job (can be changed using stty).
fg
Bring the current or specified job to the foreground.
bg
Run the current or specified jobs in the background.
jobs
List the active jobs under job control.
limit
Limit the consumption of a resource by the current process.
stop
Stop the current or specified background job.

© CSG / 2000 / help@doc.ic.ac.uk / Top of page