Ps Command in Linux (List Processes) _ Linuxize
Ps Command in Linux (List Processes) _ Linuxize
In Linux, a running instance of a program is called process. Occasionally, when working on a Linux
machine, you may need to nd out what processes are currently running.
There are number of commands that you can use to nd information about the running processes,
with ps , pstree , and top being the most commonly used ones.
This article explains how to use the ps command to list the currently running processes and
display information about those processes.
ps [OPTIONS]
For historical and compatibility reasons, the ps command accepts several different types of
options:
https://linuxize.com/post/ps-command-in-linux/ 1/9
9/22/2020 Ps Command in Linux (List Processes) | Linuxize
Different option types can be mixed, but in some particular cases, con icts can appear, so it is best
to stick with one option type.
In it’s simplest form, when used without any option, ps will print four columns of information for
minimum two processes running in the current shell, the shell itself, and the processes that run in
the shell when the command was invoked.
$ ps
The output includes information about the shell ( bash ) and the process running in this shell ( ps ,
the command that you typed):
Output
PID TTY TIME CMD
1809 pts/0 00:00:00 bash
2043 pts/0 00:00:00 ps
The four columns are labeled PID , TTY , TIME , and CMD .
PID - The process ID. Usually, when running the ps command, the most important
information the user is looking for is the process PID. Knowing the PID allows you to kill a
malfunctioning process .
https://linuxize.com/post/ps-command-in-linux/ 2/9
9/22/2020 Ps Command in Linux (List Processes) | Linuxize
CMD - The name of the command that was used to start the process.
The output above is not very useful as it doesn’t contain much information. The real power of the
ps command comes when launched with additional options.
The ps command accepts a vast number of options that can be used to display a speci c group
of processes and different information about the process, but only a handful are needed in day-to-
day usage.
BSD form:
$ ps aux
The a option tells ps to display the processes of all users. Only the processes that not
associated with a terminal and processes of group leaders are not shown.
u stands for a user-oriented format that provides detailed information about the processes.
The x option instructs ps to list the processes without a controlling terminal. Those are
mainly processes that are started on boot time and running in the background .
The command displays information in eleven columns labeled USER , PID , %CPU , %MEM , VSZ ,
RSS , STAT , START , TTY , TIME , and CMD .
Output
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.8 77616 8604 ? Ss 19:47 0:01 /sbin/i
root 2 0.0 0.0 0 0 ? S 19:47 0:00 [kthrea
...
We already explained PID , TTY , TIME and CMD labels. Here is an explanation of other labels:
https://linuxize.com/post/ps-command-in-linux/ 3/9
9/22/2020 Ps Command in Linux (List Processes) | Linuxize
$ ps auxf
The ps command also allows you to sort the output. For example, to sort the output based on the
memory usage , you would use:
$ ps aux --sort=-%mem
UNIX form:
$ ps -ef
The command displays information in eight columns labeled UID , PID , PPID , C , STIME ,
TIME , and CMD .
Output
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 19:47 ? 00:00:01 /sbin/init
root 2 0 0 19:47 ? 00:00:00 [kthreadd]
...
https://linuxize.com/post/ps-command-in-linux/ 4/9
9/22/2020 Ps Command in Linux (List Processes) | Linuxize
The labels that are not already explained have the following meaning:
To view only the processes running as a speci c user, type the following command, where
linuxize is the name of the user:
$ ps -f -U linuxize -u linuxize
For example, to print information only about the PID and COMMAND , you would run one of the
following commands:
$ ps -efo pid,comm
$ ps auxo pid,comm
https://linuxize.com/post/ps-command-in-linux/ 5/9
9/22/2020 Ps Command in Linux (List Processes) | Linuxize
BUY ME A COFFEE
Sign up to our newsletter and get our latest tutorials and news straight
to your mailbox.
Your email...
Subscribe
Related Articles
OCT 23, 2019
Pstree Command in Linux
https://linuxize.com/post/ps-command-in-linux/ 7/9
9/22/2020 Ps Command in Linux (List Processes) | Linuxize
If you want to display the output of the ps command, one page at a time pipe it to the less
command:
$ ps -ef | less
The output of the ps command can be ltered with grep . For example, to show only the process
belonging to the root user you would run:
Conclusion
The ps command is one of the most commonly used commands when troubleshooting issues on
Linux systems. It has many options, but usually, most users are using either ps aux or ps -ef
to gather information about running processes.
ps terminal
https://linuxize.com/post/ps-command-in-linux/ 6/9
9/22/2020 Ps Command in Linux (List Processes) | Linuxize
Write a comment
© 2020 Linuxize.com
https://linuxize.com/post/ps-command-in-linux/ 8/9
9/22/2020 Ps Command in Linux (List Processes) | Linuxize
https://linuxize.com/post/ps-command-in-linux/ 9/9