Skip to content

This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!


ps

ps (process status) is a program that displays the currently running processes. A related Unix utility named top provides a real-time view of the running processes.


Table of contents


Use

Reference(s)
  • Print all processes:

    $ ps -e
    

  • Print all processes with more details (additional columns):

    $ ps -ef | less
    

  • Print processes with custom columns (see "STANDARD FORMAT SPECIFIERS" section of $ man ps for more column header to display):

    $ ps ax -o pid,uname,pcpu,pmem,comm
    

  • Print processes owned by a user:

    $ ps -u user-name
    

  • Print processes by "exact" name, an "exact" process name is needed (no partial name or wildcard), e.g. sshd:

    $ ps -f -C sshd
    

  • Print processes by "partial" name, to search the process list more flexibly:

    $ ps -ef | grep ssh
    

  • Print processes by process id:

    $ ps -f -p 1036,1569,11006
    

  • Print the 10 processes that have the biggest CPU usage:

    $ ps -ef --sort=-pcpu | head -10
    

  • Print processes by memory usage:

    $ ps -ef --sort=-pmem
    

  • Print processes hierarchy in a tree style:

    $ ps -ef --forest
    

  • Print the threads of a process, e.g. threads of process id 3150:

    $ ps -p 3150 -L
    

  • Print all processes owned by you:

    $ ps -x
    

  • Print all processes associated with current terminal:

    $ ps -T
    

  • Print all processes associated with a terminal:

    $ ps -a
    

  • Print all processes NOT associated with a terminal (negation command):

    $ ps -a -N
    


If this cheat sheet has been useful to you, then please consider leaving a star here.