Introduction to ps command
In Linux, a process is any executing (running) instance of a program. Whenever you run a program, it creates a new process. Linux is a multi-tasking and multi-user operating system that allows running several programs simultaneously. So, there are multiple Linux processes running at the same time. There are different tools to view and track processes in the Linux system. This article will introduce the ps command in Linux which displays a list of currently running processes and their PIDs. ps is the short form for Process Status.
ps command syntax
The syntax for ps command is:
$ ps [option]
Some options available in ps command are as follows:
- -A: List all processes on the system
- -e: List all processes on the system
- x: List processes owned by the current user
- -f: List processes with full format
- u: Display user-oriented format
Different examples to use ps command
1. ps command to list all processes in the current shell
When ps command is used without any options or arguments, it displays a list of running processes in the current shell.
$ ps
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command in linux to list running processes](https://www.golinuxcloud.com/wp-content/uploads/ps-command-in-linux.png)
It displays the following information in the output.
- PID: It shows the unique process ID.
- TTY: It shows the terminal type into which the user is logged in.
- TIME: It displays the total time that the process has been running.
- CMD: It displays the name of the command that launches the process. As we can notice in the output, the second process is started by the ps command itself.
2. ps command to list all processes
You can use -A or -e option to list all running processes in the Linux system.
$ ps -A
OR
$ ps -e
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to list all processes](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-list-all-processes.png)
3. ps command to list all processes with a terminal
The a option causes ps to list all processes associated with a terminal (TTY).
$ ps a
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to list all processes with a terminal](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-list-all-processes-with-a-terminal.png)
The T option allows you to select all processes associated with this terminal only.
golinux@ubuntu-PC:~$ ps T
PID TTY STAT TIME COMMAND
1925 pts/1 Ss 0:00 bash
2200 pts/1 R+ 0:00 ps T
4. ps command to list processes not associated with a terminal
The -a option shows all processes except both session leaders processes not associated with a terminal.
$ ps -a
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to list all processes not associated with a terminal](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-list-all-processes-not-associated-with-a-terminal.png)
getsid().
5. ps command to list all processes owned by the current user
The x option causes ps to list all processes owned by the current user.
$ ps x
Sample Output:
Here, ps shows all processes owned by the user golinux.
![25 ps command examples in Linux [Cheat Sheet] ps command to list all processes owned by the current user](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-list-all-processes-owned-by-the-current-user.png)
6. List all processes in BSD format
You can combine a option with x option to list all running processes in BSD format.
$ ps ax
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to list all processes in bsd format](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-list-all-processes-in-bsd-format.png)
7. List processes with full-format
The -f option displays full format and the -F option displays extra full format.
$ ps f
OR
$ ps -F
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to display full format](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-display-full-format.png)
8. Display user-oriented format
The u option enables the user-oriented format and shows the information of the user who owns the processes.
$ ps u
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to display user oriented format](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-display-user-oriented-format.png)
9. Display virtual memory format
The v option allows you to display the processes in the virtual memory format.
$ ps v
Sample Output:
%MEM shows the amount of memory the process is taking up.
![25 ps command examples in Linux [Cheat Sheet] ps command to display virtual memory format](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-display-virtual-memory-format.png)
10. Display processes by effective User ID or Name
The U, -u, or --user options display processes of the specified effective user name or ID.
$ ps -u user[name or id]
OR
$ ps --user user[name or id]
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to display processes by effective user name or id](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-display-processes-by-effective-user-name.png)
11. Display processes by the real user ID or Name
The -U or --User option selects the processes by the specified real user name or ID.
$ ps -U user[name or id]
OR
$ ps --User user[name or id]
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to list processes by real user id or name](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-display-processes-by-real-user-id-or-name.png)
12. Display processes by real group ID or name
You can list processes that belong to the specified group (real group ID or name) using -G or --Group option.
$ ps -G group[name or id]
OR
$ ps --Group group[name or id]
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to display processes by real group id or name](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-display-processed-by-real-group-id-or-name.png)
13. Display processes by effective group ID or name
Similarly, you can use -g or --group option to list the processes owned by the specified effective group ID or name. The group ID will only work with -g when some group names are also specified. Otherwise, it lists the processes by session ID when only numeric IDs are specified.
ps -g group_id,group_name
OR
ps --group group_id,group_name
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to display processes by effective group id or name](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-display-processed-by-effective-group-id-or-name.png)
14. List processes by process ID
The p, -p, or --pid option allows you to list specific processes using the process ID.
$ ps p process_ID
OR
$ ps - process_ID
OR
$ ps --pid process_ID
Sample Output:
golinux@ubuntu-PC:~$ ps -p 2867
PID TTY TIME CMD
2867 pts/1 00:00:00 su
You can also specify multiple process IDs.
golinux@ubuntu-PC:~$ ps -p 1320,1322,1325
PID TTY TIME CMD
1320 ? 00:00:00 gsd-rfkill
1322 ? 00:00:00 evolution-alarm
1325 ? 00:00:00 gsd-screensaver
15. Display specific process by using the parent process ID
The --ppid option allows you to list specific processes by parent process ID.
$ ps --ppid parent_process_ID
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to list processes by ppid](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-list-processes-by-ppid.png)
16. List processes by terminal type
The t, -t, or --tty option helps to display processes having specific terminal types.
$ ps t tty_name
OR
$ ps -t tty_name
OR
$ ps --tty tty_name
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to list processes by tty list](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-list-processes-by-tty-list.png)
17. ps command to show environment after command
The e option causes ps to show the environment after commands in the output. e and -e options are not the same. The -e option helps to display all processes.
$ ps e
Sample Output:
golinux@ubuntu-PC:~$ ps e
PID TTY STAT TIME COMMAND
886 tty2 Ssl+ 0:00 /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --systemd --session=ubuntu XDG_SEAT=seat0 LOGNAME=golinux USER=golinux USE
891 tty2 Sl+ 0:56 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3 USER=golinux LC_TIME=en_GB.UTF-8 LANGUAGE=en_GB:en XDG_S
972 tty2 Sl+ 0:00 /usr/libexec/gnome-session-binary --systemd --systemd --session=ubuntu LANGUAGE=en_GB:en USER=golinux LC_TIME=en_GB.UTF-8 XDG_SEAT=seat0 XDG_SESSION_TYPE=x11 SSH_AGENT_PID=10
1840 pts/0 Ss+ 0:00 bash GJS_DEBUG_TOPICS=JS ERROR;JS LOG SSH_AUTH_SOCK=/run/user/1000/keyring/ssh SESSION_MANAGER=local/ubuntu-PC:@/tmp/.ICE-unix/1143,unix/ubuntu-PC:/tmp/.ICE-unix/1143 PAPERSI
1925 pts/1 Ss 0:00 bash GJS_DEBUG_TOPICS=JS ERROR;JS LOG SSH_AUTH_SOCK=/run/user/1000/keyring/ssh SESSION_MANAGER=local/ubuntu-PC:@/tmp/.ICE-unix/1143,unix/ubuntu-PC:/tmp/.ICE-unix/1143 PAPERSI
3042 pts/1 S 0:00 -bash SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin HOME=/home/golinux USER=golinux LOGNAME=golinux
3136 pts/1 R+ 0:00 ps e SHELL=/bin/bash LC_ADDRESS=bho_NP LC_NAME=bho_NP LC_MONETARY=bho_NP PWD=/home/golinux LOGNAME=golinux HOME=/home/golinux LC_PAPER=bho_NP LANG=en_US.UTF-8 LS_COLORS=rs=0:
18. Hide the header of ps command output
The h option hides the header in the output.
$ ps h
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to hide the headers](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-hide-the-headers.png)
19. Repeat the header lines of ps command output
The --header option is used to repeat the header lines, one per output page.
$ ps --header
Sample Output:
You will only see the effect when the output is larger than one page.
golinux@ubuntu-PC:~$ ps --headers -A
PID TTY TIME CMD
1 ? 00:00:01 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-events_highpri
9 ? 00:00:00 mm_percpu_wq
10 ? 00:00:00 rcu_tasks_rude_
11 ? 00:00:00 rcu_tasks_trace
12 ? 00:00:00 ksoftirqd/0
13 ? 00:00:00 rcu_sched
14 ? 00:00:00 migration/0
15 ? 00:00:00 idle_inject/0
16 ? 00:00:00 cpuhp/0
17 ? 00:00:00 kdevtmpfs
20. ps command to display a process tree
The f or --forest option displays an ASCII art process tree.
$ ps --forest
Sample Output:
golinux@ubuntu-PC:~$ ps --forest -A
PID TTY TIME CMD
2 ? 00:00:00 kthreadd
3 ? 00:00:00 \_ rcu_gp
4 ? 00:00:00 \_ rcu_par_gp
960 ? 00:00:00 \_ goa-identity-se
1118 ? 00:00:00 \_ at-spi-bus-laun
1124 ? 00:00:00 | \_ dbus-daemon
1137 ? 00:00:00 \_ gnome-session-c
1143 ? 00:00:00 \_ gnome-session-b
1322 ? 00:00:00 | \_ evolution-alarm
1377 ? 00:00:00 | \_ gsd-disk-utilit
1514 ? 00:00:01 | \_ update-notifier
1158 ? 00:03:26 \_ gnome-shell
1181 ? 00:00:00 | \_ ibus-daemon
1185 ? 00:00:00 | \_ ibus-dconf
1186 ? 00:00:01 | \_ ibus-extension-
1458 ? 00:00:00 | \_ ibus-engine-sim
You can print the process hierarchy using -H option.
golinux@ubuntu-PC:~$ ps -H -A
PID TTY TIME CMD
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
1832 ? 00:00:37 gnome-terminal-
1840 pts/0 00:00:00 bash
1925 pts/1 00:00:00 bash
2867 pts/1 00:00:00 su
2868 pts/1 00:00:00 bash
3041 pts/1 00:00:00 su
3042 pts/1 00:00:00 bash
4010 pts/1 00:00:00 ps
21. ps command to show threads as if they were processes
The H option allows you to show threads as if they were processes.
$ ps H
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to show threads as if they were processes](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-show-threads-as-if-they-were-processes.png)
22. Show threads with LWP and NLWP columns
The -L option show threads, possibly with LWP (lightweight process) and NLWP (number of the lightweight processes) columns.
$ ps -L
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to show threads with lwp and nlwp](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-show-threads-with-lwp-and-nlwp.png)
23. Show format specifiers with ps command
The L option shows all format specifiers.
$ ps L
Sample Output:
![25 ps command examples in Linux [Cheat Sheet] ps command to show format specifiers](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-show-format-specifiers.png)
24. Display signal format with ps command
The s option is used to display signal format.
$ ps s
Sample Output:
golinux@ubuntu-PC:~$ ps s UID PID PENDING BLOCKED IGNORED CAUGHT STAT TTY TIME COMMAND 1000 886 0000000000000000 0000000000000000 0000000000001000 0000000180014000 Ssl+ tty2 0:00 /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session 1000 891 0000000000000000 0000000000000000 0000000000001000 00000001c18066ef Rl+ tty2 1:40 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -k 1000 972 0000000000000000 0000000000000000 0000000000001000 0000000180004002 Sl+ tty2 0:00 /usr/libexec/gnome-session-binary --systemd --systemd --session=ubuntu 1000 1840 0000000000000000 0000000000000000 0000000000380004 000000004b817efb Ss+ pts/0 0:00 bash 1000 1925 0000000000000000 0000000000010000 0000000000380004 000000004b817efb Ss pts/1 0:00 bash 1000 3042 0000000000000000 0000000000010000 0000000000380004 000000004b817efb S pts/1 0:00 -bash 1000 4305 0000000000000000 0000000000000000 0000000000000000 00000001f3d1fef9 R+ pts/1 0:00 ps s
25. ps command to display security info
The -M option adds a column of security data and is used to get the security information of the processes.
$ ps -M
Sample output:
![25 ps command examples in Linux [Cheat Sheet] ps command to get security info](https://www.golinuxcloud.com/wp-content/uploads/ps-command-to-get-security-info.png)
Conclusion
This tutorial demonstrates the different examples of ps command to display information about active processes in the Linux system. It is a very useful command to monitor running processes in the system. If you still have any confusion, please feel free to ask us in the comment section.
What's Next
5 practical examples to list running processes in Linux
20 top command examples in Linux [Cheat Sheet]
Further Reading

