Review Chapter 3, Linux Files and Processes, in Linux System Administration
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 #BSD-style options
ps u
ps x
ps aux
ps -f #SysV-style options
ps -e
ps -l
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
Kill a process by process ID:
kill 1188
Kill a process by name:
pkill httpd
Kill a process that won’t die:
kill -9 1188
Kill multiple processes with the same name:
killall bash
ps aux | grep root –
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 runlevel at which init is currently running.
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.