View processes using the PS command in Linux

Home > Search > Linux commands
  by

The ps command can be used to view a static snapshot of active processes. The top command can be used to view processes in real time. The ps command without any options will display only the processes being used by the current user in the current shell.

[john.doe@server1 ]# ps
 PID  TTY        TIME  CMD
4012  pts/2  00:00:00  bash
4657  pts/2  00:00:00  ps

 


Add additional columns

The -f option can be used to add the User ID (UID), Parent PID (PPID), Child processes (C), and Start Time (STIME) columns.

[john.doe@server1 ~]$ ps -f
UID          PID  PPID  C STIME TTY          TIME CMD
john.doe   24001 23994  0 17:38 pts/2    00:00:00 bash
john.doe   24535 24001  0 18:05 pts/2    00:00:00 ps -f

 

The -F option can be used to add the User ID (UID), Parent PID (PPID), Child processes (C), Size (SZ), Real Memory Size (RSS), Process the command is assigned to (PSR), and Start Time (STIME) columns.

[john.doe@server1 ~]# ps -F
UID          PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
john.doe   24001 23994  0  6034  3836   1 17:38 pts/2    00:00:00 bash
john.doe   24547 24001  0  4981  1284   0 18:17 pts/2    00:00:00 ps -F

 


View all processes

There are many processes that do not run in a shell. For example, the init or systemd or upstart daemon does not run in a users shell, which is why a ? is displayed under the TTY column in the following example. The -A or -e or ax option can be used to view all processes.

[john.doe@server1 ]# ps -e
 PID  TTY        TIME  CMD
   1  ?      00:00:02  systemd
   2  ?      00:00:00  kthreadd
   3  ?      00:00:01  ksoftirqd/0
   . . .

 


View processes being run by a certain user

The -U option can be used to view processes being run by a certain user. In this example, root can see the processes being run by John Doe.

[root@server1 ]# ps -U john.doe
 PID  TTY        TIME  CMD
5837  tty 2  00:00:00  bash
6102  pts/3  00:00:00  sshd

 


View the process associated with a service

The -C option can be used to view the process associated with a service. In this example, the processes associated with Firefox are displayed.

[root@server1 ]# ps -C firefox
 PID  TTY        TIME  CMD
23865 ?      00:00:17  firefox

 


View the process associated with a PID

The -p option can be used to view the process associated with a certain PID. In this example, the process associated with PID 1 is displayed.

[john.doe@server1 ]# ps -p 1
 PID  TTY        TIME  CMD
   1  ?      00:00:02  systemd

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments