This guide will take you through various example usage of ps
command in Linux/Unix system. ps
, an acronym for Processes Status is a utility used to display running processes on Linux/Unix systems system. It reports a snapshot of the current system processes.
Syntax: ps [options]
ps accepts three types of options:
1.UNIX options, which may be grouped and must be preceded by a dash (-)
2. BSD options, which may be grouped and must not be used with a dash.
3. GNU long options, which are preceded by two dashes (–)
Using of ps Command in Linux
1. Display processes associated with the current shell.
When run without any arguments, ps
command displays the processes associated with the current shell.
ps
PID TTY TIME CMD
1446588 pts/0 00:00:00 bash
1570347 pts/0 00:00:00 ps
By default you will obtain the following information:
- PID The process ID of the process
- TTY The name of the terminal session (shell) that the process is running within
- TIME The amount of CPU time used by the process
- CMD The name of the command that was entered to create the process
2. To display all processes running on the system, type ps -e
or ps -A
command.
ps -e
PID TTY TIME CMD
1 ? 00:00:23 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
4 ? 00:00:00 rcu_par_gp
6 ? 00:00:00 kworker/0:0H-kblockd
8 ? 00:00:00 mm_percpu_wq
9 ? 00:00:01 ksoftirqd/0
10 ? 00:00:56 rcu_sched
ps -A
PID TTY TIME CMD
1 ? 00:00:23 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
4 ? 00:00:00 rcu_par_gp
6 ? 00:00:00 kworker/0:0H-kblockd
8 ? 00:00:00 mm_percpu_wq
9 ? 00:00:01 ksoftirqd/0
10 ? 00:00:56 rcu_sched
3.To display full-format listing, type ps -ef
or ps -eF
command.
ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 11:10 ? 00:00:23 /sbin/init splash
root 2 0 0 11:10 ? 00:00:00 [kthreadd]
root 3 2 0 11:10 ? 00:00:00 [rcu_gp]
root 4 2 0 11:10 ? 00:00:00 [rcu_par_gp]
root 6 2 0 11:10 ? 00:00:00 [kworker/0:0H-kblockd]
ps -eF
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
root 1 0 0 42347 10916 2 11:10 ? 00:00:23 /sbin/init splash
root 2 0 0 0 0 2 11:10 ? 00:00:00 [kthreadd]
root 3 2 0 0 0 0 11:10 ? 00:00:00 [rcu_gp]
root 4 2 0 0 0 0 11:10 ? 00:00:00 [rcu_par_gp]
root 6 2 0 0 0 0 11:10 ? 00:00:00 [kworker/0:0H-kblockd]
The addition information include:
- UID The user ID of the process’s owner
- PPID The PID of the process’s parent process
- C The amount of processor time utilized by the process
- RSS How much RAM is utilized at the time the command is output
- PSR Processor that process is currently assigned to
- STIME The time that the process started
4. To display long format of the ps
output, type ps -efl
or ps -eFl
command.
ps -efl
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 1 0 0 80 0 - 42347 - 11:10 ? 00:00:25 /sbin/init splash
1 S root 2 0 0 80 0 - 0 - 11:10 ? 00:00:00 [kthreadd]
1 I root 3 2 0 60 -20 - 0 - 11:10 ? 00:00:00 [rcu_gp]
1 I root 4 2 0 60 -20 - 0 - 11:10 ? 00:00:00 [rcu_par_gp]
ps -eFl
F S UID PID PPID C PRI NI ADDR SZ WCHAN RSS PSR STIME TTY TIME CMD
4 S root 1 0 0 80 0 - 42347 - 10916 1 11:10 ? 00:00:25 /sbin/init splash
1 S root 2 0 0 80 0 - 0 - 0 2 11:10 ? 00:00:00 [kthreadd]
1 I root 3 2 0 60 -20 - 0 - 0 0 11:10 ? 00:00:00 [rcu_gp]
1 I root 4 2 0 60 -20 - 0 - 0 0 11:10 ? 00:00:00 [rcu_par_gp]
We obtain the following information:
- F The flags associated with the process.
- S The state of the process. This column uses the following codes:
- D Uninterruptible sleep
- R Running
- S Interruptible sleep
- T Stopped or traced
- Z Zombie
- PRI The priority of the process.
- NI The nice value of the process.
- ADDR The memory address of the process.
- SZ The size of the process.
- WCHAN The name of the kernel function in which the process is sleeping. A dash (–) in this column means the process is currently running.
5.To display all processes in Bsd
format, type ps au
or ps aux
command.
ps au
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
frank 1975 0.0 0.0 166544 6572 tty2 Ssl+ 09:21 0:00 /usr/lib/gdm3/gdm-x-session --register-session --run-script i3
frank 1978 7.6 0.5 735048 42868 tty2 Sl+ 09:21 1:01 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -ke
frank 2001 0.0 0.1 35416 12864 tty2 S+ 09:21 0:00 i3
ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.2 0.1 168096 11876 ? Ss 09:18 0:02 /sbin/init splash
root 2 0.0 0.0 0 0 ? S 09:18 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 09:18 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 09:18 0:00 [rcu_par_gp]
6.To display all processes whose effective user ID (EUID)
or name is in the userlist, type ps -fu frank
or ps -fu 1000
command.
ps -fu frank
UID PID PPID C STIME TTY TIME CMD
frank 1880 1 0 09:21 ? 00:00:00 /lib/systemd/systemd --user
frank 1884 1880 0 09:21 ? 00:00:00 (sd-pam)
frank 1896 1880 1 09:21 ? 00:00:18 /usr/bin/pulseaudio --daemonize=no --log-target=journal
ps -fu 1000
UID PID PPID C STIME TTY TIME CMD
frank 1880 1 0 09:21 ? 00:00:00 /lib/systemd/systemd --user
frank 1884 1880 0 09:21 ? 00:00:00 (sd-pam)
frank 1896 1880 1 09:21 ? 00:00:18 /usr/bin/pulseaudio --daemonize=no --log-target=journal
7. To display processes whose real user ID (RUID)
or name is in the userlist, type ps -fU frank
or ps -fU 1000
command.
ps -fU frank
UID PID PPID C STIME TTY TIME CMD
frank 1880 1 0 09:21 ? 00:00:00 /lib/systemd/systemd --user
frank 1884 1880 0 09:21 ? 00:00:00 (sd-pam)
frank 1896 1880 1 09:21 ? 00:00:20 /usr/bin/pulseaudio --daemonize=no --log-target=journal
8. To display all processes by real group ID (RGID)
or name, type ps -fG dip
or ps -fG 30
command.
ps -fG dip
UID PID PPID C STIME TTY TIME CMD
libvirt+ 1376 1 0 09:20 ? 00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/li
ps -fG 30
UID PID PPID C STIME TTY TIME CMD
libvirt+ 1376 1 0 09:20 ? 00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/li
❯ ps -fG dip
9. To display all processes by effective group ID (EGID)
or name, type ps -fg dip
or ps -fg 30
command.
ps -fg dip
UID PID PPID C STIME TTY TIME CMD
libvirt+ 1376 1 0 09:20 ? 00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/li
10. To select processes by PID
, type ps -fp 3511
command.
ps -fp 3511
UID PID PPID C STIME TTY TIME CMD
frank 3511 1 0 09:21 pts/0 00:00:00 /usr/bin/zsh
11. To select a processes by PPID
, type ps -f --ppid 3890
command.
ps -f --ppid 3890
UID PID PPID C STIME TTY TIME CMD
frank 4246 3890 0 09:22 ? 00:00:00 /opt/google/chrome/chrome --type=utility --utility-sub-type=storage.mojom.StorageService --field-trial-handle=132069
frank 4430 3890 0 09:22 ? 00:00:18 /opt/google/chrome/chrome --type=renderer --field-trial-handle=13206994095123897317,8220222987148921566,131072 --lan
frank 4432 3890 0 09:22 ? 00:00:01 /opt/google/chrome/chrome --type=renderer --field-trial-handle=13206994095123897317,8220222987148921566,131072 --lan
12. To display ASCII
art process tree, type ps -ef --forest
command.
ps -ef --forest
root 1856 976 0 09:21 ? 00:00:00 \_ gdm-session-worker [pam/gdm-password]
frank 1975 1856 0 09:21 tty2 00:00:00 \_ /usr/lib/gdm3/gdm-x-session --register-session --run-script i3
frank 1978 1975 6 09:21 tty2 00:05:17 \_ /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keept
frank 2001 1975 0 09:21 tty2 00:00:01 \_ i3
frank 2066 2001 0 09:21 ? 00:00:00 \_ /usr/bin/ssh-agent /usr/bin/im-launch i3
13. To display a process tree for a given process, type ps -ef --forest | grep -v grep | grep zsh
command.
ps -ef --forest | grep -v grep | grep zsh
frank 3458 3318 0 09:21 pts/0 00:00:10 \_ /usr/bin/zsh
frank 3511 1 0 09:21 pts/0 00:00:00 /usr/bin/zsh
frank 3590 1 0 09:21 pts/0 00:00:00 /usr/bin/zsh
frank 3591 1 0 09:21 pts/0 00:00:00 /usr/bin/zsh
14. To select processes associated with the terminal given in tty
list, type ps -t pts/0
commands.
ps -t pts/0
PID TTY TIME CMD
3458 pts/0 00:00:12 zsh
3511 pts/0 00:00:00 zsh
3590 pts/0 00:00:00 zsh
3591 pts/0 00:00:00 zsh
3615 pts/0 00:00:00 gitstatusd-linu
292279 pts/0 00:00:00 sudo
15. To select processes whose PID
appear in pidlist, type ps -fp 1903,1947,3362
command.
ps -fp 1903,1947,3362
UID PID PPID C STIME TTY TIME CMD
frank 1903 1880 0 09:21 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
frank 1947 1880 0 09:21 ? 00:00:00 /usr/libexec/goa-identity-service
frank 3362 1880 0 09:21 ? 00:00:00 /usr/libexec/at-spi-bus-launcher
16. To display PID
of a given process name, type ps -C compton -o pid=
command.
ps -C compton -o pid=
2095
17. To display NAME
of a given PID
, type ps -q 2095 -o comm=
command.
ps -q 2095 -o comm=
compton
18. To dispaly PID,PPID,User name
and Command
of a process, type ps -eo pid,ppid,user,cmd
command.
ps -eo pid,ppid,user,cmd
PID PPID USER CMD
1982 2 root [krfcommd]
2001 1975 frank i3
2066 2001 frank /usr/bin/ssh-agent /usr/bin/im-launch i3
2084 1 frank /bin/sh -c dunst
2087 2084 frank dunst
2095 1 frank compton
2099 1 frank /bin/sh -c i3bar --bar_id=bar-0 --socket="/run/user/1000/i3/ipc-socket.2001"
19. To display a specific process by its name, type ps -C zsh
command.
ps -C zsh
PID TTY TIME CMD
3458 pts/0 00:00:12 zsh
3511 pts/0 00:00:00 zsh
3590 pts/0 00:00:00 zsh
3591 pts/0 00:00:00 zsh
20. To display execution time of a process, type ps -eo comm,etime,user | grep terminator
command.
ps -eo comm,etime,user | grep terminator
terminator 02:26:03 frank
21. To display security context (for SELinux
), type ps -eM
or ps -e --context
command.
ps -eM
LABEL PID TTY TIME CMD
unconfined 1 ? 00:00:10 systemd
unconfined 2 ? 00:00:00 kthreadd
unconfined 3 ? 00:00:00 rcu_gp
ps -e --context
PID CONTEXT COMMAND
1 unconfined /sbin/init splash
2 unconfined [kthreadd]
3 unconfined [rcu_gp]
4 unconfined [rcu_par_gp]
This is all about our guide on the usage of ps Command in Linux/Unix system.
Reference
For more information about ps
command feel free to check man
and info ps
pages respectively. If you have other ps
command usage examples drop a comment.
man ps
info ps
Other Tutorials
Upgrade a Single Package on CentOS/Fedora