List Processes

Listing Processes: ps

The ps command provides a list of current processes.

  • A process is not a thread
  • Processes run until finished
  • Processes fork: parent and child processes
  • PID
  • PPID

Note how the output of ps lets you trace from parent to child.

The output of the basic ps command:

PID TTY TIME CMD
2712 pts/1 00:00:00 bash
2727 pts/1 00:00:00 ps

  • Process ID
  • Terminal
  • CPU time
  • Command

Try:

  • ps a
  • ps u
  • ps x
  • ps aux
  • ps lax

The output of ps aux:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.3 0.2 1744 568 ? S 08:19 0:02 init [5]
root 2 0.0 0.0 0 0 ? SN 08:19 0:00 [ksoftirqd/0]
root 3 0.0 0.0 0 0 ? S 08:19 0:00 [watchdog/0]
root 4 0.0 0.0 0 0 ? S< 08:19 0:00 [events/0]
root 5 0.0 0.0 0 0 ? S< 08:19 0:00 [khelper]
root 6 0.0 0.0 0 0 ? S< 08:19 0:00 [kthread]
root 8 0.0 0.0 0 0 ? S< 08:19 0:00 [kacpid]
root 63 0.0 0.0 0 0 ? S< 08:19 0:00 [kblockd/0]
root 112 0.0 0.0 0 0 ? S 08:19 0:00 [pdflush]
root 113 0.0 0.0 0 0 ? S 08:19 0:00 [pdflush]
….

  • User name
  • Process ID
  • % of CPU utilization
  • % of RAM utilization
  • Virtual memory size
  • resident set size, the non-swapped physical memory that a task has used (in kiloBytes)
  • Terminal (TTY)
  • Status:
    • D – uninterruptible sleep
    • R – runnable (in queue)
    • S – sleeping
    • T – traced or stopped
    • Z – “zombie”
    • W – as no resident pages
    • < – high priority
    • N – low priority
    • L – has pages locked in memory
  • Start time
  • Total time
  • Command name

Finding processes for a user:

ps aux | grep root –

About the init process

Note that the init program/process controls all startup, maintenance and shutdown processes for the system. You’ll see a number in brackets after the init process, e.g. [5]. This is the number of processes init is currently controlling.

About the ps program

ps has been around a long time. There are a LOT of versions, and many, many option conventions. See the man page for discussion of the differences between System V and BSD options.