What it does
ps reads /proc once and prints a list. It accepts three option styles: UNIX (with a dash: ps -ef), BSD (without a dash: ps aux) and GNU long options (--sort). The two most used forms are ps aux and ps -ef.
With -o you choose the columns, with --sort the order — for example the processes that use the most memory.
How to write it
ps [OPTION]...Options 51
Most used
Select processes
Output format
Display
Help
Nothing matches this filter.
Examples 12
$ run as a normal user# run as root (or with sudo)
1All processes, BSD style
ps aux | head -3 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.4 174876 16420 ? Ss 07:58 0:02 /usr/lib/systemd/systemd --switched-root --system root 2 0.0 0.0 0 0 ? S 07:58 0:00 [kthreadd]Names in [ ] are kernel threads.
2All processes, UNIX style
ps -ef | grep sshdShows PPID: who started the process.
3Top memory users
ps -eo pid,user,%mem,rss,cmd --sort=-%mem | headFirst check when a server swaps or the OOM killer acts.
4Top CPU users
ps aux --sort=-%cpu | head -5Snapshot; use top for a live view.
5One process by name
ps -C httpd -o pid,ppid,user,cmdhttpd runs a root parent and apache children.
6The process tree
ps -ef --forest | lessShows which child belongs to which parent.
7Processes of one user
ps -u lisa -o pid,tty,stat,cmdWhat a user runs before you lock the account.
8Find zombies and stuck processes
ps -eo pid,ppid,stat,cmd | awk '$3 ~ /^[ZD]/'Z = zombie, D = waiting for disk (often NFS or a bad disk).
9SELinux contexts of services
ps -eZ | grep httpd system_u:system_r:httpd_t:s0 1420 ? 00:00:00 httpdThe type httpd_t confines the web server.
10Threads of a process
ps -L -p $(pidof chronyd)One line per thread.
11Start time and run time
ps -o pid,lstart,etime,cmd -p 1010When did the service start, how long does it run?
12Find processes started from /tmp (security)
ps -eo pid,user,cmd | grep -E '(/tmp|/dev/shm)/'Malware often runs from these folders.
Nothing matches this filter.
Watch out
ps -aux(with a dash) is not the same asps aux; use the BSD form without a dash.- ps is a snapshot. Values like %CPU are averages over the life of the process.
Exit codes
0 :: Done. 1 :: Error, or no process matched a selection.