From LQWiki
Jump to: navigation, search

The ps command lists processes. The command options determine both which processes are listed and the format of the output. Unlike most commands, some of the options to ps do not use the hyphen ("-"), so some letters have different meanings with and without the hyphen.


$ ps -fu username            # "full listing" of user's processes.
$ ps -fe                     # "full listing" of all processes.
$ ps auxf                    # "really full listing" of all processes.

The following script kills all processes running by another user (if you are the superuser)

$user_pids=`ps au | tr -s ' ' | cut -d' ' -f1,2 | grep $username \
| cut -d' ' -f2`
for pid in $user_pids
   kill -9 $pid

To find a list of offending processes

ps auxw | grep [name-of-executable]

Running pkill afterward might also be nice.

PS Tips & Tricks

  • List processes by memory usage (ascending): ps -eo pid,%mem,cmd --sort rsz
  • For a full listing of all processes: ps -ef

See also

  • top - displays a continuously updating list of processes.
  • pstree - displays a chart showing the hierarchy of processes.
  • kill - send a signal to a process
  • pgrep - list processes matching given criteria.

External links