___________ __________ _____ ________ ________ .____ ___________ \_ _____/ \______ \ / _ \ / _____/ / _____/ | | \_ _____/ | __) | _/ / /_\ \ / \ ___ / \ ___ | | | __)_ | \ | | \ / | \ \ \_\ \ \ \_\ \ | |___ | \ \___ / |____|_ / \____|__ / \______ / \______ / |_______ \ /_______ / \/ \/ \/ \/ \/ \/ \/

ps Cheatsheet

← Back to cheatsheets

← Home


ps (process status) displays information about running processes. Shows process IDs, resource usage, and command lines. Essential for system monitoring and process management.


Basic Usage

  • ps - List processes in current session
  • ps aux - All processes (BSD style)
  • ps -ef - All processes (System V style)
  • ps -e - All processes
  • ps -f - Full format
  • ps -u user - User processes

Common Options

  • -a - All processes except session leaders
  • -e - All processes
  • -f - Full format
  • -l - Long format
  • -u user - User processes
  • -p PID - Specific PID
  • -C command - Command name
  • -x - Include processes without TTY

Output Format

  • ps aux - User-oriented format
  • ps -ef - Full format
  • ps -l - Long format
  • ps -o format - Custom format
  • ps --forest - Tree format
  • ps --sort key - Sort by key

Custom Columns

  • ps -o pid,comm,cmd - Custom columns
  • ps -o pid,user,%mem,%cpu - Resource usage
  • ps -o pid,etime,cmd - Elapsed time
  • ps -o pid,ppid,cmd - Parent process

Common Examples

All Processes

ps aux

List all processes with details.

User Processes

ps -u username

Processes for specific user.

Specific Process

ps -p 1234

Information about PID.

Command Search

ps -C firefox

Find process by command.

Tree Format

ps --forest

Show process tree.

Custom Format

ps -o pid,%mem,%cpu,cmd

Custom columns.

Sort by Memory

ps aux --sort=-%mem | head

Top memory consumers.

Sort by CPU

ps aux --sort=-%cpu | head

Top CPU consumers.

Full Command

ps -f -p 1234

Full command line.

Elapsed Time

ps -o pid,etime,cmd

Show how long process has run.


Common Fields

  • PID - Process ID
  • PPID - Parent Process ID
  • USER - Process owner
  • %CPU - CPU usage
  • %MEM - Memory usage
  • VSZ - Virtual memory size
  • RSS - Resident set size
  • TTY - Terminal
  • STAT - Process state
  • START - Start time
  • TIME - CPU time
  • COMMAND - Command line

Tips

  • Use ps aux for comprehensive view
  • Use --sort to find resource hogs
  • Use --forest to see process trees
  • Combine with grep to filter
  • Use -o for custom output
  • Essential for system monitoring
  • Check STAT column for process state
  • Use with kill for process management