Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

ps on Its Own

ps
    PID TTY          TIME CMD
   4211 pts/0    00:00:00 bash
   4380 pts/0    00:00:00 ps

Without options, ps lists only the processes of your current terminal. On Ubuntu, Debian, AlmaLinux, and Rocky Linux, ps comes from the procps package, so the options below are the same everywhere.

ps aux: Every Process

ps aux | head -5
ColumnMeaning
USEROwner
PIDProcess ID
%CPUCPU share, lifetime average
%MEMShare of physical memory
VSZVirtual memory, KiB
RSSMemory in RAM, KiB
TTYTerminal, ? if none
STATState, see below
STARTStart time
TIMECPU time used
COMMANDCommand line

%CPU is averaged over the life of the process, so a busy moment hardly shows; for live values use the top command. RSS counts shared libraries in every process that uses them, so adding up the column overstates memory use.

ps -ef and Parent PIDs

ps -ef | head -5

The columns are UID, PID, PPID, C, STIME, TTY, TIME, and CMD. PPID is the parent process ID, which tells you what started a process. To see the parent of one process, run ps -o ppid= -p 1234. A process whose parent is PID 1 was started by systemd or was left behind by a parent that exited.

Two Option Styles

ps accepts BSD-style options without a dash (aux), UNIX-style options with a dash (-ef), and long options (--sort). Both styles list every process; they differ in the columns. Write aux without a dash: with a dash, ps may read it as a request for a user named "x".

Sort and Choose Columns

ps aux --sort=-%mem | head -10
ps -eo pid,user,%cpu,%mem,etime,cmd --sort=-%cpu | head

A minus sign before the sort key means largest first. -o names the columns you want; etime is the time since the process started. An equals sign after a column name hides the header, which helps in scripts: ps -o pid= -C nginx.

Filter by User or Name

ps -u www-data
ps -f -C nginx
pgrep -a nginx

-u selects a user and -C a command name. ps aux | grep nginx also works but lists the grep process itself; pgrep avoids that and prints the PID with the full command line. More ways to list processes are in how to list processes in Linux.

Process Tree and Threads

ps -ef --forest
ps -eLf | head
ps -o nlwp= -p 1234

--forest draws each process under its parent. -L prints one line per thread, with the thread ID in the LWP column, and nlwp gives the number of threads of one process.

Process States

CodeState
RRunning or ready
SSleeping, waiting
DWaiting on I/O, uninterruptible
TStopped
ZZombie
IIdle kernel thread

Extra characters follow the letter: < high priority, N low priority, s session leader, l multithreaded, + in the foreground. Many processes in D point to slow storage; see how to check disk I/O in Linux. A zombie has finished and holds only an entry in the process table, but its parent has not collected its exit status; restarting the parent clears it.

From ps to Action

Once you have the PID, how to kill a process in Linux shows how to stop it safely. If the process belongs to a service, stop it with systemctl instead, or systemd may start it again.

Was this answer helpful?
Loading...