The ps command invokes the process table, a record that summarizes the currently running processes on a system. When the command is run without any option, it displays the processes run by the current shell with details such as the PID, the terminal associated with the process, the accumulated CPU time, and the command that started the process. However, different options may be used along with the command to filter the displayed fields or processes.


The syntax of the ps command is:

Command Option Syntax Styles

The ps command supports three different styles of command option syntax: Unix- style (preceded by a hyphen), GNU-style (preceded by two hyphens), and BSD-style (no hyphen). Mixing these styles will not always produce the same results. For example, the ps command (BSD-style) will print all processes with a controlling terminal, including session leaders (the first member of a group of processes). It will also print the status of each process, as well as the full command (including options) of each process. The ps -a command (Unix-style) also prints all processes with a controlling terminal, but does not include session leaders, the status of each process, nor the full command of each process.

ps Command Options

The ps command supports several options. Some of the more prominent options are listed here.

Option Used To
a List all user-triggered processes.
-e List all processes.
-l List processes using a long listing format.
u List processes along with the user name and start time.
r Exclude processes that are not running currently.
x Include processes without a terminal.
T Exclude processes that were started by any terminal other than the current one.
-U {user name} Display the processes based on the specified user.
-p {PID} Display only the process associated with the specified PID.
-C {command} Display all processes by command name.
–tty {terminal number} Display all processes running on the specified terminal.

ps Command Examples

1. To see the zombie process:

# ps aux | awk '{ print $8 " " $2 }' | grep -w Z

2. Listing zombie processes:

3. To find/list the running processes:

4. Find processes for a particular user:

# ps -U apache
# ps U apache
# ps -u apache

5. To see every process running as root (real & effective ID) in user format:

6. To find/list the processes which has in its command execution:

7. List the processes based on PIDs:

8. pgrep, pkill – look up or signal processes based on name and other attributes:

# pgrep 1234
# pkill 1234 OR # pkill httpd

9. Sorting the ps output:

# ps -eo uname,pid,ppid,nlwp,pcpu,pmem,psr,start_time,tty,time,args --sort -pcpu,-pmem

10. To print a process tree:

11. Print only the process IDs of syslogd:

12. Print only the name of PID 42:

13. List the Process based on the UID and Commands:

# ps -f -u wwwrun,postfix

14. List the processes based on PIDs or PPIDs:

15. List Processes in a Hierarchy:

#  ps -e -o pid,args --forest

16. List elapsed wall time for processes:

# ps -p 1,29675 -o pid,etime=

17. To list the process hierarchy:

# ps -e -o pid,args --forest
# ps axjf
# ps -ejH

18. List all threads for a particular process:

# ps -C java -L -o pid,tid,pcpu,state,nlwp,args

19. To display a tree of processes:

20. To list elapsed wall time for processes:

# ps -p 1,29675 -o pid,etime=

21. To get the process start time:

22. Display full information about each of the processes currently running:

23. To get info about threads:

24. To get security info:

# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps -eM

25. To see every process with a user-defined format:

# ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
# ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
# ps -eopid,tt,user,fname,tmout,f,wchan

26. List all threads for a particular process:

# ps -C java -L -o pid,tid,pcpu,state,nlwp,args