Ps and pstree
This article describes the purpose of the Unix-tools ps and pstree. Furthermore, the most important options as well as their functions are presented.
Information
ps (process status) is an unix-command that displays an overview of all processes running on the system and its status. pstree (process tree) represents graphically the hierarchy of the processes in a tree topology. A comparable tool under Windows would be tasklist.exe.
Installation
The programs ps and pstree are normally contained in the default settings of the different Linux distributions. Otherwise, they can be installed via following packages:
procps for ps
psmisc for pstree
Meaning of the columns displayed
- UID = ID of the user that has started this process
- PID = clear process-ID
- STIME = time, when the process was started
- TTY = states the terminal, on which the process is running
- TIME = total system time used by the process
- CMD = name of the program that has started the process
Example of screen output
- extract from ps without options:
benutzer:~$ ps PID TTY TIME CMD 2897 pts/1 00:00:00 bash 2914 pts/1 00:00:00 ps
- excerpt from pstree:
benutzer:~$ pstree
init─┬─/usr/lib/glippe
├─NetworkManager─┬─dhclient
│ └─{NetworkManager}
├─acpid
├─atd
├─avahi-daemon───avahi-daemon
├─bluetoothd
├─bonobo-activati───{bonobo-activat}
├─clock-applet
├─console-kit-dae───63*[{console-kit-da}]
├─cron
[...]
Important options and its functions
All of the options listed below can be combined with each other to limit or extend the output to what is necessary!
- listing of all processes
ps -e
- displaying of extended information
ps -f
Example:
benutzer:~$ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 08:09 ? 00:00:01 /sbin/init root 2 0 0 08:09 ? 00:00:00 [kthreadd] root 3 2 0 08:09 ? 00:00:00 [migration/0] root 4 2 0 08:09 ? 00:00:00 [ksoftirqd/0] root 5 2 0 08:09 ? 00:00:00 [watchdog/0] root 6 2 0 08:09 ? 00:00:00 [migration/1] root 7 2 0 08:09 ? 00:00:00 [ksoftirqd/1] root 8 2 0 08:09 ? 00:00:00 [watchdog/1] root 9 2 0 08:09 ? 00:00:00 [migration/2] root 10 2 0 08:09 ? 00:00:00 [ksoftirqd/2] root 11 2 0 08:09 ? 00:00:00 [watchdog/2] root 12 2 0 08:09 ? 00:00:00 [migration/3] root 13 2 0 08:09 ? 00:00:00 [ksoftirqd/3] root 14 2 0 08:09 ? 00:00:00 [watchdog/3] root 15 2 0 08:09 ? 00:00:00 [events/0] [...]
- displaying of process status
ps -x
- reducing of list on running processes
ps r
Output of all running processes with extended information
ps -ef
Output of memory occupancy per process
ps aux --sort -rss
Note: rss stands for resident set size - here is the excerpt of the ps manpage:
- resident set size, the non-swapped physical memory that a task has used (inkiloBytes)
Graphical presentation of process hierarchy
- simple structure:
ps axjf
- better representation:
pstree </pre
| Translator: Alina Ranzinger Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department. |

