Note :- in this documentation, an example username "ug12abc" is given. You should use your own username in its place.

Essentially, any running program is called a process.  The way Linux works means that a computer may be running a large number of independent processes, owned by different users.

Foreground and Background Processes

To understand the difference between foreground and background processes try the following.

Go to an xterm and type


and press return.  Now if you try and type something in the xterm, you will not be able to.  This is because gedit was started as a foreground process and is now the sole focus of attention.

Close gedit (select Quit in the File menu) and type this in the xterm

gedit &

and press return.  If you try typing in the xterm now, it should work as normal.  This is because adding the & after a command makes it run in the background.

If you've started a program without the & and want to change it to a background process, then you don't need to exit it and start again.  Simply go to the xterm and press CTRL+Z - you should see the following.



Now just type bg and the process will be changed into a background process.  Typing fg will have the reverse effect on the first background process you started.

Monitoring and killing processes

Background processes are very useful.  However they have one major drawback - sometimes they don't stop until you tell them to.  This can cause a great deal of frustration if you log out and leave a process running, as it will continue to use the processing power of the computer whilst the next person is trying to use it.  Most processes do shut down if you log off, but it is a good idea to exit all of your programs before you log off.

Monitoring Processes

To enable you to do anything to a process you need to know its process identification number (PID). There are several ways to do this.

  1. When you start a process, the PID will be displayed. For example try:
    gedit &
    and you will see something like [1] 2531, the second number (2531) is the PID of that process.
  2. While the program is running, type:
    ps -u ug12abc
    This will print a list of processes and their PID's
  3. Alternatively type:
    This will give a list of the top CPU processes.  If you press u and then enter your username then the list will be limited to your processes only. Press q to quit top.

Killing Processes

If you need to kill a process then you need to know its PID (see above).  Once you know it then all you have to type is kill PID.  If a process refuses to end type

kill -9 PID