1. Home
  2. Computing & Technology
  3. Linux

GNU/Linux Command-Line Tools Summary

From Authors, About.com Guest


   GNU/Linux Command-Line Tools Summary
   Prev    Chapter 9. Controlling the system    Next

9.3. Controlling Processes

  • ps
  •    

    Will give you a list of the processes running on your system. With no options, ps will list processes that belong to the current user and have a controlling terminal.

    Example options include:

    • -aux --- list all running processes (by all users with some information).

    • -a --- list all processes from all users.

    • -u --- list more information including user names, %cpu usage, and %mem usage et cetera.

    • -x --- list processes without controlling terminals.

    • -l --- display different information including UID and nice value.

    • --forest --- this makes it easier to see the process hierarchy, which will give you an indication of how the various processes on your system interrelate (although you should also try pstree ).

    For example to list all running processes with additional information, simply type:


       

    ps -aux


  • pstree
  •    

    Displays the processes in the form of a tree structure (similar to how tree does it for directories).

    Use the -p option to show process id's.

    Example:


       

    pstree -p

    This would list all processes and their id's.


  • pgrep
  •    

    This command is useful for finding the process id of a particular process when you know part of its name.

    Use the -l option to list the name of the process as well and the -u option to search via a particular user(s).

    Normally pgrep will only return the pid number; this way you can use it with other commands.

    Examples:


       

    kill $(pgrep mozilla)

    This would kill any process name that starts with mozilla. Note that this is the same as using pkill (see below).

    If you are unfamiliar with the $( ) part of this command, please refer to Section 6.4 .

    To list processes id's and names type:


       

    pgrep -l process_name


  • top
  •    

    Displays the 'top' (as in CPU usage) processes, provides more detail than ps .

    top also provides an updated display, it has many options that make it fully customisable, refer to the manual or info page for details.


  • kill
  •    

    To kill processes on your system, you will need their pid's or id's . Use ps or pstree to find out the process id's (pid's), or use jobs to find out id's.


           killall and pkill - kill a process by name
            

    pkill and killall can be a lot easier to use than kill . pkill allows you to type part of the name of a process to kill it, while killall requires the full process name. See below for more information.

    Examples:


       

    kill pid

    Simply kill a process (allow it time to save it's files and exit)


       

    kill %id

    Same as above, except it uses an id instead of a pid, you need to use a % (percent) when using an id to kill.


       

    kill -kill pid

    Force a process to be killed (won't allow files to be saved or updated) ; only use when necessary because all data that the program had will be lost.

    There are also many other kill options such as kill -HUP (hangup)... refer to the manual/info pages for more

* License

* GNU/Linux Command-Line Tools Summary Index

Explore Linux
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Documentation
  5. Linux Tools Summary
  6. GNU/Linux Command-Line Tools Summary - Controlling Processes

©2009 About.com, a part of The New York Times Company.

All rights reserved.