Cyberithub

31 Popular ps command in Linux/Unix with Examples(Monitor Linux Processes)

Table of Contents

Advertisements

In this article, i will take you through 31 Popular ps command in Linux with Examples. As you might be aware a running program is known as Process in System. Linux based OS are a multitasking system so you might see multiple process running simultaneously. The other concept that you might have heard is about a light weight process known as thread.

Linux has a free open source utility called ps to perform process management in the System. This utility by default comes with Linux/Unix based Systems hence you don't have to install it manually. ps command reads information from /proc virtual filesystem and displays you the output. We will go through multiple examples of ps command to understand its usages and functions.

Synopsis

ps [options]

31 Popular ps command in Linux/Unix with Examples(Monitor Linux Processes) 1

ps command in Linux/Unix with Examples

Also Read: 33 Practical Examples of ulimit command in Linux/Unix for Professionals

Example 1: How to check ps command version

If you want to check ps command version then you need to use ps --version command as shown below. As you can see from below output, current ps command version is 3.3.10.

[root@ip-172-31-33-220 ~]# ps --version
procps-ng version 3.3.10

--version : Print the procps-ng version.

NOTE:

Please note that here I am using root user to run all the below commands.You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.

Example 2: How to check all the processes using ps command in Linux/Unix(ps -ef)

If you want to check all the processes running in the system, then you need to use ps -ef command as shown below. This command will show complete information about all the processes in the System. Hence the output of this command could be little comprehensive.

[root@localhost ~]# ps -ef
UID  PID PPID C STIME TTY TIME      CMD
root  1   0   7 19:38 ?   00:00:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root  2   0   0 19:38 ?   00:00:00 [kthreadd]
root  3   2   0 19:38 ?   00:00:00 [kworker/0:0]
root  4   2   0 19:38 ?   00:00:00 [kworker/0:0H]
root  5   2   0 19:38 ?   00:00:00 [kworker/u30:0]
root  6   2   0 19:38 ?   00:00:00 [ksoftirqd/0]
root  7   2   0 19:38 ?   00:00:00 [migration/0]
root  8   2   0 19:38 ?   00:00:00 [rcu_bh]
root  9   2   0 19:38 ?   00:00:00 [rcu_sched]
root  10  2   0 19:38 ?   00:00:00 [lru-add-drain]
root  11  2   0 19:38 ?   00:00:00 [watchdog/0]
root  12  2   0 19:38 ?   00:00:00 [watchdog/1]
root  13  2   0 19:38 ?   00:00:00 [migration/1]
root  14  2   0 19:38 ?   00:00:00 [ksoftirqd/1]
root  15  2   0 19:38 ?   00:00:00 [kworker/1:0]
root  16  2   0 19:38 ?   00:00:00 [kworker/1:0H]
root  17  2   0 19:38 ?   00:00:00 [watchdog/2]
root  18  2   0 19:38 ?   00:00:00 [migration/2]
root  19  2   0 19:38 ?   00:00:00 [ksoftirqd/2]
root  20  2   0 19:38 ?   00:00:00 [kworker/2:0]
root  21  2   0 19:38 ?   00:00:00 [kworker/2:0H]

-e : Select all processes. Check ps command Man Page for more info.

-f : Do full-format listing. Check ps command Man Page for more info.

Example 3: How to show all the processes running with a specific user(ps -u) in Linux/Unix

If you want to show all the processes running with a specific user then you need to use -u option with ps command as shown below. In this example we are trying to show all the processes running with user root by using ps -u root command.

[root@localhost ~]# ps -u root
PID TTY TIME     CMD
1    ?  00:00:05 systemd
2    ?  00:00:00 kthreadd
3    ?  00:00:00 kworker/0:0
4    ?  00:00:00 kworker/0:0H
5    ?  00:00:00 kworker/u30:0
6    ?  00:00:00 ksoftirqd/0
7    ?  00:00:00 migration/0
8    ?  00:00:00 rcu_bh
9    ?  00:00:00 rcu_sched
10   ?  00:00:00 lru-add-drain
11   ?  00:00:00 watchdog/0
12   ?  00:00:00 watchdog/1
13   ?  00:00:00 migration/1
14   ?  00:00:00 ksoftirqd/1
15   ?  00:00:00 kworker/1:0
16   ?  00:00:00 kworker/1:0H
17   ?  00:00:00 watchdog/2
18   ?  00:00:00 migration/2
19   ?  00:00:00 ksoftirqd/2
20   ?  00:00:00 kworker/2:0

-u : Select by effective user ID (EUID) or name.

Example 4: How to Check process name using Process ID(PID)

If you want to check a process name using its process Id(PID) then you need to use -q option with ps command as shown below. In this example, we are trying to check the process name of PID 34 using ps -q 34 -o comm= command.

[root@localhost ~]# ps -q 34 -o comm=
ksoftirqd/5

-q : Select by process ID (quick mode). Check ps command Man Page for more info.

-o : User-defined format. Check ps command Man Page for more info.

Example 5: How to Check all the Processes in Long Listing format(ps ax) in Linux/Unix

If you want to check all the processes in Long Listing Format then you need to use ps ax command as shown below.

[root@localhost ~]# ps ax
PID TTY STAT TIME COMMAND
1    ?   Ss  0:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
2    ?   S   0:00 [kthreadd]
4    ?   S<  0:00 [kworker/0:0H]
5    ?   S   0:00 [kworker/u30:0]
6    ?   S   0:00 [ksoftirqd/0]
7    ?   S   0:00 [migration/0]
8    ?   S   0:00 [rcu_bh]
9    ?   S   0:01 [rcu_sched]
10   ?   S<  0:00 [lru-add-drain]
11   ?   S   0:00 [watchdog/0]
12   ?   S   0:00 [watchdog/1]
13   ?   S   0:00 [migration/1]
14   ?   S   0:00 [ksoftirqd/1]
16   ?   S<  0:00 [kworker/1:0H]
17   ?   S   0:00 [watchdog/2]
18   ?   S   0:00 [migration/2]
19   ?   S   0:00 [ksoftirqd/2]
21   ?   S<  0:00 [kworker/2:0H]
22   ?   S   0:00 [watchdog/3]
23   ?   S   0:00 [migration/3]
24   ?   S   0:00 [ksoftirqd/3]
26   ?   S<  0:00 [kworker/3:0H]
27   ?   S   0:00 [watchdog/4]
28   ?   S   0:00 [migration/4]
29   ?   S   0:00 [ksoftirqd/4]
31   ?   S<  0:00 [kworker/4:0H]
32   ?   S   0:00 [watchdog/5]
33   ?   S   0:00 [migration/5]
34   ?   S   0:00 [ksoftirqd/5]
36   ?   S<  0:00 [kworker/5:0H]
37   ?   S   0:00 [watchdog/6]
38   ?   S   0:00 [migration/6]

a : Lift the BSD-style "only yourself" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like.

x : Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like.

Example 6: How to display all User processes with its Real User ID(ps -fU) in Linux/Unix

If you want to display User processes with its Real User ID then you need to use -U option with ps command as shown below. In this example, we are trying to display centos user processes by using ps -fU centos command.

[root@localhost ~]# ps -fU centos
UID    PID  PPID C STIME TTY   TIME     CMD
centos 8565 7668 0 19:39 ?     00:00:00 sshd: centos@pts/0
centos 8667 8565 0 19:39 pts/0 00:00:00 -bash

-U : Select by real user ID (RUID) or name. Check ps command Man Page for more info.

Example 7: How to display all User processes with its effective User ID(ps -fu) in Linux/Unix

If you want to display User processes with its effective User ID then you need to use -u option with ps command as shown below. In this example, we are trying to display centos user processes by using ps -fu centos command.

[root@localhost ~]# ps -fu centos
UID    PID  PPID C STIME TTY   TIME     CMD
centos 7478 7468 0 21:09 ?     00:00:00 sshd: centos@pts/1
centos 7482 7478 0 21:09 pts/1 00:00:00 -bash
centos 8565 7668 0 19:39 ?     00:00:00 sshd: centos@pts/0
centos 8667 8565 0 19:39 pts/0 00:00:00 -bash

Example 8: How to count total number of processes using ps command in Linux/Unix(ps -ef)

If you want to count total number of processes then you need to use wc command with ps command in Linux as shown below. As you can see from below output as of now total number of processes is 504.

[root@localhost ~]# ps -ef | wc -l
504

Example 9: How to find the Process by Process ID using ps command in Linux/Unix(ps -p)

If you want to find some process by its Process ID(PID) then you need to use -p option with ps command in Linux as shown below. In this example, we are trying to find out a process with a PID 7478 using ps -p 7478 command.

[root@localhost ~]# ps -p 7478
PID TTY TIME     CMD
7478 ?  00:00:00 sshd

-p : Select by PID. Check ps command Man Page for more info.

Example 10: How to Select all Processes by Command Name(ps -C) 

If you want to show all the processes by its command name then you need to use -C option with ps command in Linux as shown below. In this example, we are trying to show all the processes running for sshd command using ps -C sshd command.

[root@localhost ~]# ps -C sshd
PID TTY TIME     CMD
2266 ?  00:00:00 sshd
7468 ?  00:00:00 sshd
7478 ?  00:00:00 sshd
7668 ?  00:00:00 sshd
8565 ?  00:00:00 sshd
11344 ? 00:00:00 sshd
11389 ? 00:00:00 sshd
25087 ? 00:00:00 sshd

-C : Select by command name. Check ps command Man Page for more info.

Example 11: How to show all the processes running as root user using ps command in Linux(ps -U)

If you want to show all the processes running as root user with its effective and real User ID then you need to use both -u and -U option with ps command in Linux. In this example we are trying to show all the processes of root user with its effective and Real User ID using ps -U root -u root command.

[root@localhost ~]# ps -U root -u root
PID TTY TIME     CMD
1    ?  00:00:05 systemd
2    ?  00:00:00 kthreadd
4    ?  00:00:00 kworker/0:0H
5    ?  00:00:00 kworker/u30:0
6    ?  00:00:05 ksoftirqd/0
7    ?  00:00:00 migration/0
8    ?  00:00:00 rcu_bh
9    ?  00:02:27 rcu_sched
10   ?  00:00:00 lru-add-drain
11   ?  00:00:00 watchdog/0
12   ?  00:00:00 watchdog/1
13   ?  00:00:00 migration/1
14   ?  00:00:05 ksoftirqd/1
16   ?  00:00:00 kworker/1:0H

-U : Select by real user ID (RUID) or name.

-u : Select by effective user ID (EUID) or name.

Example 12: How to show all the processes with Real Group ID using ps command in Linux(ps -fG)

If you want to show the processes with its Real Group ID then you need to use -G option with ps command in Linux as shown below. In this example we are trying to show the processes with Real Group ID root using ps -fG root command.

[root@localhost ~]# ps -fG root
UID PID PPID C STIME TTY TIME     CMD
root 1   0   0 19:38 ?   00:00:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root 2   0   0 19:38 ?   00:00:00 [kthreadd]
root 4   2   0 19:38 ?   00:00:00 [kworker/0:0H]
root 5   2   0 19:38 ?   00:00:00 [kworker/u30:0]
root 6   2   0 19:38 ?   00:00:06 [ksoftirqd/0]
root 7   2   0 19:38 ?   00:00:00 [migration/0]
root 8   2   0 19:38 ?   00:00:00 [rcu_bh]
root 9   2   2 19:38 ?   00:02:47 [rcu_sched]
root 10  2   0 19:38 ?   00:00:00 [lru-add-drain]
root 11  2   0 19:38 ?   00:00:00 [watchdog/0]
root 12  2   0 19:38 ?   00:00:00 [watchdog/1]

-G : Select by real group ID (RGID) or name.

Example 13: How to show all the processes with Effective Group ID(ps -fg)

If you want to show all the processes with its Effective Group ID then you need to use -g option with ps command in Linux as shown below. In this example we are trying to show the processes with Effective Group ID root using ps -fg root command.

[root@localhost ~]# ps -fg root
UID PID PPID C STIME TTY TIME      CMD
root 1   0   0 19:38 ?   00:00:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root 2   0   0 19:38 ?   00:00:00 [kthreadd]
root 4   2   0 19:38 ?   00:00:00 [kworker/0:0H]
root 5   2   0 19:38 ?   00:00:00 [kworker/u30:0]
root 6   2   0 19:38 ?   00:00:07 [ksoftirqd/0]
root 7   2   0 19:38 ?   00:00:00 [migration/0]
root 8   2   0 19:38 ?   00:00:00 [rcu_bh]
root 9   2   2 19:38 ?   00:03:00 [rcu_sched]
root 10  2   0 19:38 ?   00:00:00 [lru-add-drain]
root 11  2   0 19:38 ?   00:00:00 [watchdog/0]
root 12  2   0 19:38 ?   00:00:00 [watchdog/1]
root 13  2   0 19:38 ?   00:00:00 [migration/1]
root 14  2   0 19:38 ?   00:00:06 [ksoftirqd/1]

-g : Select by session OR by effective group name.

Example 14: How to see all the processes in BSD Syntax(ps aux)

If you want to see all the processes in BSD Syntax then you need to use ps aux command as shown below.

[root@localhost ~]# ps aux
USER PID %CPU %MEM VSZ       RSS TTY STAT START TIME COMMAND
root  1   0.0  0.0 468927    376  ?   Ss  19:38 0:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root  2   0.0  0.0 0         0    ?   S   19:38 0:00 [kthreadd]
root  4   0.0  0.0 0         0    ?   S<  19:38 0:00 [kworker/0:0H]
root  5   0.0  0.0 0         0    ?   S   19:38 0:00 [kworker/u30:0]
root  6   0.1  0.0 0         0    ?   S   19:38 0:10 [ksoftirqd/0]
root  7   0.0  0.0 0         0    ?   S   19:38 0:00 [migration/0]
root  8   0.0  0.0 0         0    ?   S   19:38 0:00 [rcu_bh]
root  9   2.9  0.0 0         0    ?   S   19:38 4:17 [rcu_sched]
root  10  0.0  0.0 0         0    ?   S<  19:38 0:00 [lru-add-drain]
root  11  0.0  0.0 0         0    ?   S   19:38 0:00 [watchdog/0]
root  12  0.0  0.0 0         0    ?   S   19:38 0:00 [watchdog/1]

Example 15: How to show a process tree using ps command in Linux/Unix(ps -ejH)

If you want to show all the processes in a process tree form then you need to use ps -ejH command as shown below.

[root@localhost ~]# ps -ejH
PID   PGID SID  TTY    TIME     CMD
2     0     0    ?     00:00:00 kthreadd
1     1     1    ?     00:00:05 systemd
939   939   939  ?     00:00:03 systemd-journal
978   978   978  ?     00:00:00 systemd-udevd
1199  1199  1199 ?     00:00:00 auditd
1630  1630  1630 ?     00:00:00 rpcbind
1634  1634  1634 ?     00:00:00 systemd-logind
1636  1636  1636 ?     00:00:00 irqbalance
1637  1637  1637 ?     00:00:00 dbus-daemon
1642  1642  1642 ?     00:00:00 polkitd
1668  1668  1668 ?     00:00:00 gssproxy
2038  2038  2038 ?     00:00:00 dhclient
2097  2097  2097 ?     00:00:02 tuned
2210  2210  2210 ?     00:00:00 master
2220  2210  2210 ?     00:00:00 qmgr
16355 2210  2210 ?     00:00:00 pickup
2260  2260  2260 ?     00:00:04 rsyslogd
2266  2266  2266 ?     00:00:00 sshd
7668  7668  7668 ?     00:00:00 sshd
8565  7668  7668 ?     00:00:00 sshd
8667  8667  8667 pts/0 00:00:00 bash
10297 10297 8667 pts/0 00:00:00 sudo
10299 10299 8667 pts/0 00:00:00 bash
7468  7468 7468  ?     00:00:00 sshd
7478  7468 7468  ?     00:00:01 sshd
7482  7482 7482  pts/1 00:00:00 bash
7713  7713 7482  pts/1 00:00:00 sudo
7715  7715 7482  pts/1 00:00:00 bash
25835 25835 7482 pts/1 00:00:00 ps

-j : Jobs format.

-H : Show process hierarchy (forest).

Example 16: How to Show Process Tree of a command using ps command in Linux(ps -f)

If you want to show process tree of a command then you need to use --forest option with ps command as shown below. In this example we are trying to show the process tree of sshd command using ps -f --forest -C sshd command.

[root@localhost ~]# ps -f --forest -C sshd
UID    PID   PPID  C STIME TTY  TIME           CMD
root   25087 10197 0 19:41  ?   00:00:00 /usr/sbin/sshd
root   2266   1    0 19:39  ?   00:00:00 /usr/sbin/sshd -D
root   7668  2266  0 19:39  ?   00:00:00 \_ sshd: centos [priv]
centos 8565  7668  0 19:39  ?   00:00:00 | \_ sshd: centos@pts/0
root   7468  2266  0 21:09  ?   00:00:00 \_ sshd: centos [priv]
centos 7478  7468  0 21:09  ?   00:00:02 | \_ sshd: centos@pts/1
root   23233 2266  0 22:42  ?   00:00:00 \_ sshd: [accepted]
sshd   23254 23233 0 22:42  ?   00:00:00 \_ sshd: [net]

--forest : ASCII art process tree.

Example 17: How to Select Processes by TTY(ps -t) using ps command in Linux

If you want to show all the processes by TTY then you need to use -t option with ps command in Linux as shown below. In this example we are trying to show all the processes running on terminal pts/0 by using ps -t pts/0 command.

[root@localhost ~]# ps -t pts/0
PID   TTY     TIME   CMD
28103 pts/0 00:00:00 bash
28300 pts/0 00:00:00 sudo
28302 pts/0 00:00:00 bash
29221 pts/0 00:00:00 ps

-t : Select by tty.

Example 18: How to Select a Process by PPID using ps command in Linux

If you want to select a process by PPID then you need to use --ppid option with ps command in Linux as shown below. In this example we are trying to select a process with PPID 18042 using ps -f --ppid 18042 command.

[root@localhost ~]# ps -f --ppid 18042
UID  PID   PPID  C STIME TTY TIME     CMD
root 32618 18042 0 11:45 ?   00:00:00 sleep 60

--ppid : Select by parent process ID.

Example 19: How to Show all Processes Sorted by Memory Utilization in Descending Order

If you want to show all the processes sorted by memory utilization in descending order then you need use --sort=-%mem option with ps command in Linux and feed the ps command output to head command as shown below.

[root@localhost ~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
PID   PPID             CMD              %MEM %CPU
18033 18025 /usr/bin/java -server -Djav 23.5 2.1
30497 30471 java -server -Xmx1024m -Xms 2.7  19.3
15401 15397 java -ea -javaagent:./../li 2.7  5.1
18139 18096 java -server -Xmx1024m -Xms 2.4  7.2
13859 11108 /usr/lib/erlang/erts-5.8.5/ 1.6  0.3
16048 16041 /usr/lib/jvm/java-openjdk/b 1.6  2.0
10113 10083 java -classpath /opt/report 1.4  2.0
17721 17716 java -Xmx1024m -Xms1024m -s 1.4  3.7
13411 13405 java -classpath /opt/barist 1.4  3.0

--sort : Specify sorting order.

-e : Show the environment after the command.

-o : User-defined format.

Example 20: How to Show All Processes Sorted by CPU Utilization in Descending Order

If you want to show all the processes sorted by cpu utilization in descending order then you need use --sort=-%cpu option with ps command in Linux and feed the ps command output to head command as shown below.

[root@localhost ~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head
PID   PPID             CMD               %MEM %CPU
30497 30471  java -server -Xmx1024m -Xms 2.7  19.2
18139 18096  java -server -Xmx1024m -Xms 2.4  7.2
2799    1    /usr/bin/kubelet --bootstra 0.2  5.2
15401 15397  java -ea -javaagent:./../li 2.7  5.0
3662  3633   kube-controller-manager --r 0.2  4.8
3650  3619   kube-apiserver --endpoint-r 0.7  3.7
17721 17716  java -Xmx1024m -Xms1024m -s 1.4  3.7
13359 10365  /usr/bin/java -Djava.util.l 0.7  3.3
31373 31371  java -Xmx512m -Xms512m -jar 1.1  3.3

Example 21: How to Show All Processes Sorted by RSS in Descending Order

If you want to show all the processes sorted by rss utilization in descending order then you need use --sort=-%rss option with ps command in Linux and feed the ps command output to head command as shown below.

[root@localhost ~]# ps -eo pid,ppid,cmd,%mem,%cpu,rss --sort=-rss | head
PID   PPID              CMD             %MEM %CPU RSS
18033 18025 /usr/bin/java -server -Djav 23.5 1.1  7722528
30497 30471 java -server -Xmx1024m -Xms 2.8  16.7 918252
15401 15397 java -ea -javaagent:./../li 2.7  3.6  914516
18139 18096 java -server -Xmx1024m -Xms 2.4  6.1  801572
17721 17716 java -Xmx1024m -Xms1024m -s 1.9  2.6  626384
13859 11108 /usr/lib/erlang/erts-5.8.5/ 1.6  0.1  551400
16048 16041 /usr/lib/jvm/java-openjdk/b 1.6  1.0  550380
10113 10083 java -classpath /opt/report 1.5  0.9  512336
13411 13405 java -classpath /opt/barist 1.4  1.3  474084

Example 22: How to Show all Processes Sorted by Memory Utilization in Ascending Order

If you want to show all the processes sorted by memory utilization in descending order then you need to use --sort=-%mem option with ps command in Linux and feed the ps command output to tail command as shown below.

[root@localhost ~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | tail
6015 2 [kworker/2:166] 0.0 0.0
6102 2 [kworker/4:213] 0.0 0.0
6103 2 [kworker/4:214] 0.0 0.0
6114 2 [kworker/3:251] 0.0 0.0
6118 2 [kworker/3:254] 0.0 0.0
11687 2 [kworker/2:0] 0.0 0.0
12231 2 [dio/xvda1] 0.0 0.0
15265 15264 [python] <defunct> 0.0 0.0
23019 2 [kworker/5:1] 0.0 0.0
27360 2 [kworker/5:2] 0.0 0.0

Example 23: How to Show All Processes Sorted by CPU Utilization in Ascending Order

If you want to show all the processes sorted by cpu utilization in descending order then you need use --sort=-%cpu option with ps command in Linux and feed the ps command output to tail command as shown below.

[root@localhost ~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | tail
28300 28103 sudo -i 0.0 0.0
28302 28300 -bash 0.0 0.0
30471 18092 java -cp /opt/storm/apache- 0.1 0.0
31279 2640 docker-containerd-shim -nam 0.0 0.0
31297 31279 /bin/sh -c chmod -R 777 /lo 0.0 0.0
31327 31297 /bin/bash /on_start.sh 0.0 0.0
31358 31327 /usr/bin/python /usr/bin/su 0.0 0.0
31371 31358 /bin/sh /opt/workflow-engin 0.0 0.0
31372 31358 runuser -g root root -c /op 0.0 0.0
31374 31372 /bin/bash /opt/registry-age 0.0 0.0

Example 24: How to Show All Processes Sorted by RSS in Ascending Order

If you want to show all the processes sorted by rss utilization in descending order then you need use --sort=-%rss option with ps command in Linux and feed the ps command output to tail command as shown below.

[root@localhost ~]# ps -eo pid,ppid,cmd,%mem,rss --sort=-rss | tail
6015  2     [kworker/2:166]    0.0 0
6102  2     [kworker/4:213]    0.0 0
6103  2     [kworker/4:214]    0.0 0
6114  2     [kworker/3:251]    0.0 0
6118  2     [kworker/3:254]    0.0 0
8260  2     [kworker/5:1]      0.0 0
11687 2     [kworker/2:0]      0.0 0
12231 2     [dio/xvda1]        0.0 0
15265 15264 [python] <defunct> 0.0 0
27360 2     [kworker/5:2]      0.0 0

Example 25: How to Check All Zombie Processes using ps command in Linux

If you want to check all Zombie processes running in your Linux System then you need to use below ps command.

[root@localhost ~]# ps aux | grep Z
USER PID  %CPU %MEM VSZ   RSS  TTY   STAT START TIME COMMAND
root 15265 0.0  0.0  0     0    ?     Z   11:40 0:00 [python] <defunct>
root 18919 0.0  0.0 112716 940 pts/1  S+  12:44 0:00 grep --color=auto Z

Example 26: How To Check All Orphan Processes using ps command in Linux

If you want to check all Orphan Processes then you need to use below ps command in Linux.

[root@localhost ~]# ps -elf | head -1; ps -elf | awk '{if ($5 == 1 && $3 != "root") {print $0}}' | head
F S UID     PID PPID C PRI NI  ADDR   SZ     WCHAN  STIME TTY     TIME        CMD
5 S rpc     1631 1   0 80  0    -    17319   poll_s 11:39 ?     00:00:00 /sbin/rpcbind -w
4 S polkitd 1635 1   0 80  0    -    153061  poll_s 11:39 ?     00:00:00 /usr/lib/polkit-1/polkitd --no-debug
4 S dbus    1669 1   0 80  0    -    16576   ep_pol 11:39 ?     00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

Example 27: How to Check Running time of processes in Linux(ps -eo)

If you want to check running time of processes in Linux then you need to use below ps command. In this example we are trying to check the running time of all java based processes.

[root@localhost ~]# ps -eo comm,etime,user,pid | grep java
java 01:24:09 513 10113
java 01:24:07 520 10335
java 01:24:03 506 10755
java 01:23:58 root 11260
java 01:23:57 root 11468
java 01:23:55 root 12113
java 01:23:47 514 13045
java 01:23:47 root 13047
java 01:23:46 504 13161
java 01:23:45 root 13359
java 01:23:44 502 13411
java 01:23:37 503 14001
java 01:23:33 532 14365

Example 28: How to Print Security Information about the Processes(ps -eM)

If you want to show security information about the processes then you need to use ps -eM command as shown below.

[root@localhost ~]# ps -eM | more
LABEL                         PID TTY  TIME     CMD
system_u:system_r:init_t:s0    1   ?   00:00:04 systemd
system_u:system_r:kernel_t:s0  2   ?   00:00:00 kthreadd
system_u:system_r:kernel_t:s0  4   ?   00:00:00 kworker/0:0H
system_u:system_r:kernel_t:s0  6   ?   00:00:00 ksoftirqd/0
system_u:system_r:kernel_t:s0  7   ?   00:00:00 migration/0
system_u:system_r:kernel_t:s0  8   ?   00:00:00 rcu_bh
system_u:system_r:kernel_t:s0  9   ?   00:00:10 rcu_sched
system_u:system_r:kernel_t:s0 10   ?   00:00:00 lru-add-drain
system_u:system_r:kernel_t:s0 11   ?   00:00:00 watchdog/0
system_u:system_r:kernel_t:s0 12   ?   00:00:00 watchdog/1
system_u:system_r:kernel_t:s0 13   ?   00:00:00 migration/1

-M : Add a column of security data.

Example 29: How to show threads as if they were processes(ps -ef H)

If you want to show threads as if they were processes then you need to use ps -ef H command as shown below.

[root@localhost ~]# ps -ef H 
UID    PID PPID C STIME TTY STAT  TIME CMD
root   939  1   0 11:38 ?    Ss   0:02 /usr/lib/systemd/systemd-journald
root   986  1   0 11:38 ?    Ss   0:00 /usr/lib/systemd/systemd-udevd
root   1064 2   0 11:38 ?    S<   0:00 [ttm_swap]
root   1067 1   0 11:38 ?    S<sl 0:00 /sbin/auditd
root   1067 1   0 11:38 ?    S<sl 0:00 /sbin/auditd
rpc    1631 1   0 11:39 ?    Ss   0:00 /sbin/rpcbind -w
root   1632 1   0 11:39 ?    Ss   0:00 /usr/sbin/irqbalance --foreground
root   1634 1   0 11:39 ?    Ssl  0:00 /usr/sbin/gssproxy -D
root   1634 1   0 11:39 ?    Ssl  0:00 /usr/sbin/gssproxy -D
root   1634 1   0 11:39 ?    Ssl  0:00 /usr/sbin/gssproxy -D
root   1634 1   0 11:39 ?    Ssl  0:00 /usr/sbin/gssproxy -D
root   1634 1   0 11:39 ?    Ssl  0:00 /usr/sbin/gssproxy -D
root   1634 1   0 11:39 ?    Ssl  0:00 /usr/sbin/gssproxy -D

Example 30: How to Show Threads After Processes in Linux(ps -ef m)

If you want to see threads after processes in Linux then you need to use ps -ef m command as shown below.

[root@localhost ~]# ps -ef m
UID  PID   PPID C STIME TTY STAT TIME CMD
root 1646   1   0 11:39 ?    -   0:00 /usr/lib/systemd/systemd-logind
root -      -   0 11:39 -    Ss  0:00 -
dbus 1669   1   0 11:39 ?    -   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
dbus -      -   0 11:39 -    Ssl 0:00 -
dbus -      -   0 11:39 -    Ssl 0:00 -
root 1784   2   0 13:01 ?    -   0:00 [kworker/7:1]
root -      -   0 13:01 -    S   0:00 -
root 2042   1   0 11:39 ?    -   0:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H ip-172-31-33-220 et
h0
root -      -   0 11:39 -    Ss  0:00 -
root 2102   1   0 11:39 ?    -   0:00 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
root -      -   0 11:39 -    Ssl 0:00 -
root -      -   0 11:39 -    Ssl 0:00 -
root -      -   0 11:39 -    Ssl 0:00 -
root -      -   0 11:39 -    Ssl 0:00 -
root -      -   0 11:39 -    Ssl 0:00 -

Example 31: How to check help of ps command different Options

If you want to check all the available options with ps command in Linux then you need to use --help with ps command as shown below.

[root@localhost ~]# ps --help threads

Usage:
ps [options]

Show threads:
H as if they were processes
-L possibly with LWP and NLWP columns
-m, m after processes
-T possibly with SPID column

 

 

 

 

Popular Recommendations:-

20 Popular Examples of cat command in Linux/Unix for Beginners

How to Install Rust Programming Language in Linux Using 6 Best Steps

How to Install PHP on Ubuntu 18.04

How to Install PHP on RedHat/CentOS 7 with Easy Steps

How to Install Ruby on Ubuntu 18.04 with Easy Steps

How to Install Ruby on CentOS/RedHat 7 in 5 Easy Steps

Install NPM and Node.js in 6 Easy Steps on CentOS 7

Install Node.js in 6 Easy Steps on Ubuntu 18.04

How to Install NVM for Node.js on Ubuntu 18.04

30 Useful ps command in Linux for Process Monitoring

How to Check Orphan Process in Linux

Leave a Comment