Processes Controlling commands

PS command

 

Ps command is included with procps rpm/package which 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

 

For example to list all running processes with additional information

 

  • # ps −aux

 

PSTREE command

 

Pstree command is included with psmisc rpm/package which 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.

 

For example :

 

  • # pstree -apG

 

 

A sample output screen-caps below.

 

 

Pstree

 

 

PGREP command

 

 

pgrep command (included with procps rpm/package) 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. For example to list processes id’s and names type:

 

  • # pgrep −l process_name

 

 

Pgrep

TOP command

 

Displays the ‘top‘ (as in CPU usage) processes (included with procps rpm/packages), provides more detail than ps. Top also provides an updated display, it has many options that make it fully customizable, refer to the manual or info page for details.

 

Sample screen-caps below.

 

 

Top Command

 

 

KILL command

 

To kill processes on your system (included with util-linux rpm/package), 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.

 

For example :

 

  • # 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. There are also many other kill options such as kill −HUP (hangup)… refer to the manual/info pages for more information.

 

KILLALL command

 

Kill a process by it’s name, uses names instead of process id’s (pid’s). Use −v to have killall report whether the kill was successful or not and −i for interactive mode (will prompt you before attempting to kill).

 

For example:

 

  • # killall −iv httpd

 

PKILL command

 

pkill is used to kill processes according to an extended regular expression. Use the −u option to kill using a user name(s) and process name (for example to only kill a process of a certain user). pkill can also send specific signals to processes.

 

For normal usage simply type:

 

  • # pkill process_name

 

Note that the “process_name” doesn’t have to be an exact match.

 

SKILL command

 

skill is used to send a command/username/tty a particular signal. skill has a number of options available to ensure correct interpretation. Check the man page for more details.

 

For example to kill the tty1 terminal.

  • # skill -kill tty1

 

FG command

 

Fg command bring a process to the foreground, so you can interact with it.

 

For example :

 

  • # fg job_number
  • # fg job_name

 

NICE command

 

Sets the priority for a process. nice −20 is the maximum priority (only administrative users can assign negative priorities), nice 20
is the minimum priority. You must be root to give a process a higher priority, but you can always lower the priority of your own
processes…

 

For example :

 

  • # nice −20 make

 

Would execute make and it would run at maximum priority.

 

Renice command

 

Changes the priority of an existing command. You may use the options −u to change the priorities of all processes for a particular user name and −g to change priorities for all processes of a particular group. The default is to change via the process id number.

 

For example :

 

  • # renice +20 2221

 

This would change the priority of process 2221 to +20 (minimum priority).

 

SNICE command

 

Snice works very similarly to skill, only it changes the priority of the process(es). Its function is similar to that of renice.

 

For example :

 

  • # snice −10 −u root

 

This would increase the priority of all root’s processes.