How to Use the Ps Command in Linux

Ps Command in Linux: List and Inspect Processes

To inspect one running program, you first need to pick it out of the process list. The ps command prints a point-in-time listing of selected processes and their attributes.

I’ll explain what ps shows and show how to find a process by ID or executable name.

TL;DR: The ps command in Linux

Use ps to inspect a one-time snapshot of selected processes, then add options to widen the list or show specific fields.

  • Run ps -e -f to list all processes with full-format columns.
  • Use ps -p PID or ps -C name to select a process.
  • Use top when you need a view that refreshes.

What does the ps command show?

A process is a running instance of a program. ps reports selected processes and their attributes in a point-in-time listing.

The default view follows your effective user ID and controlling terminal. TTY names that terminal, TIME is accumulated CPU time, and CMD is the executable name.

Linux procps ps accepts Unix options with a dash, BSD options without one, and GNU long options with two dashes. The same letter can have different behavior depending on the style.

ps -e -o pid,ppid,tty,stat,comm

This command selects the columns explicitly: process ID, parent process ID, terminal, state and command name.

How to use the ps command in Linux step by step

Choose columns with -o for a narrower view of the process list.

Step 1: List every process with full details

The command includes all processes in full format.

ps -e -f

The CMD column includes the command and its arguments when available.

Step 2: Find a process by PID or executable name

Use -p to inspect a known process ID. This example selects process 1 and shows its parent, terminal, state and executable name.

ps -p 1 -o pid,ppid,tty,stat,comm
    PID    PPID TT       STAT COMMAND
      1       0 ?        Ss   systemd
ps output showing systemd process ID and state
ps -p 1 -o pid,ppid,tty,stat,comm

The output identifies PID 1 as systemd, with parent PID 0 and state Ss. The state begins with S, meaning interruptible sleep.

Use -C when you know the executable’s exact name. Replace sshd with a name that exists on your system. This filter matches the executable name, so a process that has exited will not appear in the result.

Step 3: Check a process owner and its children

The --ppid option returns direct children of a parent process ID. User selection filters by owner, while this option follows the parent-child link.

ps -u ubuntu -o pid,comm | head -n 8
    PID COMMAND
   1246 systemd
   1254 (sd-pam)
   1526 cloudflared
   3710 python
 381307 dbus-daemon
 381308 at-spi-bus-laun
 381318 dbus-daemon
ps output listing process IDs and command names for a user
ps -u ubuntu -o pid,comm | head -n 8

Selection options can be additive, so one selector may not cancel another.

Step 4: Read state, memory and thread fields

This example uses a custom format to display state and memory values. RSS is resident memory in KiB, while VSZ is virtual memory in KiB. Neither value gives a complete measure of a program’s memory cost.

ps -e -o pid,stat,pcpu,pmem,rss,vsz,comm --sort=-pcpu

The %CPU value summarizes CPU use over the process lifetime.

To inspect threads as separate rows, add -L. The LWP column identifies each thread, while PID remains the process identifier.

ps -e -L -o pid,lwp,nlwp,comm

Step 5: Show parent and child processes as a tree

Add --forest to a full all-process listing when the parent-child layout helps explain how a program was started.

ps -e -f --forest

Use the tree view to trace parent-child relationships.

Common ps selection and output issues

The spelling -aux is ambiguous because procps can treat x as a username when that user does not exist. Use ps aux for BSD-style selection or ps -e -f for Unix-style selection.

Unix -a and -d both omit session leaders. The -a option selects terminal-associated processes, while -d also includes processes without a terminal.

The -T option selects processes attached to the current terminal. Use -o when you need different columns in those rows. The -f option adds fields such as UID, PPID and start time, while uppercase -F requests extra fields such as size and processor information.

Use --sort with a field name to order a listing, such as --sort=-pcpu for descending CPU percentage. For a stable view on a busy machine, sort by PID instead.

CommandWhat it selects or showsUse it for
ps -e -fAll processes in full formatGeneral process inventory
ps auxBSD-style all-user view with user-oriented columnsFamiliar resource summary
ps -u USERProcesses selected by effective userOne user’s process list
ps -C NAMEProcesses with matching executable nameKnown program lookup

If a process vanishes before inspection, repeat ps or use pgrep. For a live changing view, use top.

Terminal width can truncate the command line. Choose a wide-output option to show more text.

Finding a PID does not stop a program. When you decide that a process needs a signal, read the Linux kill command guide first. To identify the program holding a network port, see how to find open ports in Linux.

Conclusion: Use ps for a process snapshot

Use ps when you need a selected list to inspect, then choose the next command from the process details you found.

For the next step, the LinuxForDevices guides to common Linux commands and the kill command cover related process tasks.

FAQ

These answers clear up common questions about process listings.

What does ps aux show in Linux?

ps aux uses BSD-style options to show processes across users, including those without a terminal, with user-oriented columns such as CPU and memory fields.

What is the difference between ps -ef and ps aux?

ps -ef uses Unix-style options to select all processes and show full format. ps aux uses BSD-style options and displays a user-oriented format. Both provide a process snapshot.

Does ps update continuously?

No. ps prints a snapshot and exits. Use top when you need a periodically refreshed process view.