Linux ps command – 20 Real Life Examples

Filed Under: UNIX/Linux

The ps command, short for Process Status, is a command line utility that is used to display or view information related to the processes running in a Linux system.

As we all know, Linux is a multitasking and multiprocessing system. Therefore, multiple processes can run concurrently without affecting each other.

The ps command lists current running processes alongside their PIDs and other attributes. In this guide, we are going to focus on ps command usage.

It retrieves information about the processes from virtual files which are located in the /proc file system

ps command without arguments

The ps command without arguments lists the running processes in the current shell



ps command

The output consists of four columns

PID – This is the unique process ID

TTY – This is the typeof terminal that the user is logged in to

TIME – This is the time in minutes and seconds that the process has been running

CMD – The command that launched the process

Viewing all the running processes in different formats

To have a glance at all the running processes, execute the command below

ps -A


ps -A command


ps -e


ps  -e command

View processes associated with the terminal

To view processes associated with the terminal run

ps -T


ps -T command

View processes not associated with terminal

To view all processes with the exception of processes associated with the terminal and session leaders

ps -a

A session leader is a process that starts other processes


ps -a command

Show all current running processes

To view all current processes execute

ps -ax


ps -ax command

-a flag stands for all processes
-xwill display all processes even those not associated with the current tty

Display all processes in BSD format

If you wish to display processes in BSD format, execute

ps au 


ps aux


ps aux

To perform full format listing

To view a full format listing run

ps -ef 


ps -eF


ps -ef command

Filter processes according to the user

If you wish to list processes associated with a specific user, use the -u flag as shown

ps -u user

For example

ps -u jamie


ps-u username command

Filter process by thread process

If you wish to know the thread of a particular process, make use of the -Lflag followed by the PID

For example

ps -L 4264


ps -L PID command

Show every process running as root

Sometimes, you may want to reveal all processes run by the root user. To achieve this run

ps -U root -u root



Display group processes

If you wish to list all processes associated by a certain group run

ps -fG group_name


ps -fG groupID

For example

ps -fG root


ps -fG group_name

Search Process PID

Chances are that usually don’t know the PID to a process. You can search the PID of a process by

ps -C process_name

For example

ps -C bash


ps -c processname

Listing processes by PID

You can display processes by their PID as shown

ps -fp PID

For example

ps -fp 1294


ps -fp PID command

To display process hierarchy in a tree diagram

Usually, most processes are forked from parent processes. Getting to know this parent-child relationship
can come in handy. The command below searches for processes going by the name apache2

ps -f --forest -C bash


ps -f --forest -C command

Display child processes of a parent process

For example, If you wish to display all forked processes belonging to apache, execute

ps -o pid,uname,comm -C bash


ps -o pid,uname,comm -C command

The first process, which is owned by root is the main apache2 process and the rest of the processes
have been forked from this main process

To display all the child apache2 processes using the pid of the main apache2 process execute

ps --ppid PID no.

For example

ps --ppid 1294


ps --ppid PID no. command

Display process threads

The ps command can be used to view threads along with the processes.

The command below displays all the threads owned by the process with PID pid_no

ps -p pid_no -L

For example

ps -p 1294 -L 


ps -p pid_no -L

Display a selected list of columns

You can use the ps command to display only the columns you need.

For example ,

ps -e -o pid,uname,pcpu,pmem,comm

The command above will only display the PID, Username, CPU, memory and command columns


ps -e -o pid,uname,pcpu,pmem,comm

Renaming column labels

To rename column labels execute the command below

 ps -e -o pid=PID,uname=USERNAME,pcpu=CPU_USAGE,pmem=%MEM,comm=COMMAND


ps rename  columns

Display elapsed time of processes

Elapsed time refers to how long the process has been running for

ps -e -o pid,comm,etime


ps -e -o pid,comm,etime

The -o option enables the column for elapsed time

Using ps command with grep

the ps command can be used with grep command to search for a particular process

For example

ps -ef  | grep systemd


ps and grep command

Generic selectors
Exact matches only
Search in title
Search in content