ps (process status) prints a snapshot of the processes running on a Linux system. Unlike top or htop it does not refresh,
which makes it ideal for scripts, quick checks and piping into grep, sort or awk.
This guide explains the two styles you will see everywhere, ps aux and ps -ef, what each column means, and the handful of options that answer real questions:
is it running? who started it? what is using all the memory?
Quick answer: ps aux lists every process with CPU and memory; ps aux --sort=-%mem | head shows the biggest memory users; pgrep -a nginx finds a process by name.
ps With No Options
Plain ps shows only processes started from your current terminal, which is rarely what you want on a server. Add options to see the whole system.
ps
# PID TTY TIME CMD
# 2214 pts/0 00:00:00 bash
# 2290 pts/0 00:00:00 ps

ps aux: Every Process With CPU and Memory
ps aux (BSD style, no dash) lists all processes for all users with %CPU, %MEM, VSZ (virtual size), RSS (resident memory in KB), STAT (state) and START time.
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 168000 11800 ? Ss Nov20 0:09 /sbin/init
mysql 912 2.3 18.4 2.1g 1.4g ? Ssl Nov20 41:12 /usr/sbin/mariadbd
www 1503 0.4 1.2 310m 98m ? S 09:14 0:21 php-fpm: pool www

ps -ef: The System V Style
ps -ef shows the same processes with PPID (parent PID) and full command lines, which is handy for seeing what started a process. Add -F for extra size columns.
ps -ef
ps -eF | head
ps aux and ps -ef list the same processes. Use aux for resource usage and -ef for parent-child relationships.
Read Process States (STAT)
The STAT column tells you what a process is doing: R running, S sleeping, D uninterruptible sleep (usually waiting on disk or NFS), T stopped, Z zombie. Extra letters add detail, such as s session leader and + foreground.
ps -eo pid,stat,cmd | awk '$2 ~ /^D/'
ps -eo pid,ppid,stat,cmd | awk '$3 ~ /^Z/'
D state usually mean slow or hung storage. Zombies are cleaned up by their parent; see the zombie process check script.
Find a Process by Name
Piping into grep works but also matches the grep command itself. pgrep or ps -C are cleaner.
ps aux | grep [n]ginx # the [n] trick hides the grep line
pgrep -a nginx # PID and command line
ps -C nginx -o pid,user,%cpu,%mem,cmd

Sort by CPU or Memory
--sort orders the output; a minus sign sorts descending. Combined with head, it is the fastest way to answer what is eating the server.
ps aux --sort=-%mem | head -11
ps aux --sort=-%cpu | head -11
top for live load.
Show the Process Tree
Tree views show which process started which, for example the worker processes under a web server master or a runaway child of a cron job.
ps -ef --forest | less
ps -o pid,ppid,cmd --ppid 1503 # children of PID 1503
pstree -p | less

Choose Your Own Columns
-o (or -eo for all processes) prints only the fields you name, which keeps scripts simple. etime shows how long a process has been running.
ps -eo pid,user,%cpu,%mem,etime,cmd --sort=-%cpu | head
ps -p 912 -o pid,etime,rss,cmd # one PID
ps -u www-data -o pid,cmd # one user

Quick Reference
What does ps aux mean?
a lists processes of all users, u shows user-oriented columns such as %CPU and %MEM, and x includes processes without a terminal, such as daemons.
What is the difference between ps aux and ps -ef?
Both list every process. ps aux (BSD style) shows CPU and memory usage; ps -ef (System V style) shows the parent PID and start time.
How do I find a process by name in Linux?
Use pgrep -a name, or ps aux | grep [n]ame so the grep command itself is not listed.
How do I see which process uses the most memory?
Run ps aux --sort=-%mem | head. The RSS column shows resident memory in kilobytes.
What does a process in D state mean?
D is uninterruptible sleep: the process is waiting on I/O, usually disk or network storage, and cannot be killed until the I/O finishes.
Cheat Sheet
ps aux,ps -ef,ps -ef --forestps aux --sort=-%mem | head,pgrep -a name,ps -eo pid,etime,cmd
Related tutorials
Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.