Mastering Linux ps Command Guide | Generated by AI

Home 2026.02

I’ll give you a comprehensive introduction to the ps command and its options for listing processes.

What is ps?

The ps command displays information about active processes on a Unix/Linux system. It’s one of the most fundamental tools for process management and system monitoring.

Basic Usage

The simplest form shows processes for the current user in the current terminal:

ps

Common Option Styles

The ps command has three different option styles that can be mixed:

  1. Unix options - preceded by a dash (e.g., -e)
  2. BSD options - no dash (e.g., aux)
  3. GNU long options - two dashes (e.g., --forest)

Most Useful Commands

See all processes for all users:

ps aux          # BSD style
ps -ef          # Unix style

See processes in a tree/hierarchy:

ps auxf         # BSD style with forest view
ps -ef --forest # Unix style with tree

See processes for a specific user:

ps -u username
ps aux | grep username

See processes by PID:

ps -p 1234
ps -p 1234,5678,9101  # multiple PIDs

Key Options Explained

BSD Style (no dash)

Unix Style (with dash)

Understanding the Output

When you run ps aux, you’ll see columns like:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

Custom Output Formats

You can customize which columns to display:

ps -eo pid,user,%cpu,%mem,command
ps aux --sort=-%cpu | head    # top CPU users
ps aux --sort=-%mem | head    # top memory users

Practical Examples

Find a specific process:

ps aux | grep firefox

Show threads:

ps -eLf          # all threads
ps -T -p 1234    # threads for specific PID

Watch processes in real-time:

watch -n 1 'ps aux --sort=-%cpu | head -20'

See process with full command line:

ps auxww | grep process_name

Count processes:

ps aux | wc -l

See process tree from specific process:

ps -ef --forest | grep -A 5 process_name

Commonly Used Combinations

ps aux              # Everything, detailed
ps -ef              # Everything, different format
ps auxf             # Everything with hierarchy
ps -u $(whoami)     # Just your processes
ps -C httpd         # All httpd processes
ps -p $$            # Current shell process

Tips

The ps command is incredibly versatile. Start with ps aux or ps -ef for general overview, then add options as needed for more specific information.


Back Donate