{"id":2019,"date":"2014-11-19T20:00:27","date_gmt":"2014-11-19T20:00:27","guid":{"rendered":"http:\/\/linoxide.com\/how-tos\/linux-ps-command-examples-2\/"},"modified":"2026-01-30T05:51:37","modified_gmt":"2026-01-30T05:51:37","slug":"linux-ps-command-examples-2","status":"publish","type":"post","link":"https:\/\/linoxide.com\/linux-ps-command-examples-2\/","title":{"rendered":"15 Linux ps Command with Examples"},"content":{"rendered":"\n<p>The&nbsp;<strong>ps<\/strong>&nbsp;is a built-in command used in Unix\/Linux operating systems to list out the currently running processes. It displays a static snapshot with information about the processes whereas top, htop, and glances show repetitive updates.<\/p>\n\n\n\n<p>Ps command comes with lots of options to manipulate the outputs. It pulls all information of the processes from \/proc virtual filesystem.<\/p>\n\n\n\n<p>This tutorial will focus on explaining the way to use the ps command along with some practical examples<\/p>\n\n\n\n<p><strong>The syntax of ps command<\/strong><\/p>\n\n\n\n<p>The basic syntax for ps command usage is as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps &#91;options]<\/code><\/pre>\n\n\n\n<p>The \u2018options\u2019 of the ps command may be:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>UNIX options \u2013 preceded by a dash<\/li>\n\n\n\n<li>BSD options \u2013 must be used without a dash<\/li>\n\n\n\n<li>GNU long options \u2013 preceded by two dashes<\/li>\n<\/ul>\n\n\n\n<p>This is a very basic ps command usage. Just type&nbsp;\u2018ps\u2019&nbsp;on your console to see its result:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps<\/code><\/pre>\n\n\n\n<p>By default, it shows us four columns of information.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PID is a Process ID of the running command (CMD)<\/li>\n\n\n\n<li>TTY is a place where the running command runs<\/li>\n\n\n\n<li>TIME tell about how much time is used by CPU while running the command<\/li>\n\n\n\n<li>CMD is a command that runs as a current process<\/li>\n<\/ul>\n\n\n\n<p>Running ps command without any option is just a simplest format of the command, it returns not much information. In order to make the most of power of the ps command, let\u2019s run it with additional options which will be explained in further detail in the following sections.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">01) Display all processes (UNIX format)<\/h2>\n\n\n\n<p>To view all of the processes in your Linux system, you can run either of the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -A<\/code><\/pre>\n\n\n\n<p>or:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -e<\/code><\/pre>\n\n\n\n<p>Moreover, in order to list all of the running processes, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">02) Display all processes (BSD format)<\/h2>\n\n\n\n<p>In order to see all of the processes on your Linux system using the ps command in BSD format, you can run the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps ax<\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps aux<\/code><\/pre>\n\n\n\n<p>Where:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>USER \u2013 the user runs the process<\/li>\n\n\n\n<li>PID \u2013 the process id<\/li>\n\n\n\n<li>%CPU \/ %MEM \u2013 the percentage of CPU \/ RAM being occupied by the processes<\/li>\n\n\n\n<li>VSZ \u2013 the virtual memory size being occupied by the processes<\/li>\n\n\n\n<li>RSS \u2013 the size of physical memory being occupied by the processes<\/li>\n\n\n\n<li>START \u2013 start time<\/li>\n\n\n\n<li>STAT \u2013 the state of the process in which: S (sleeping), R (running), I (interruptible sleep).<\/li>\n\n\n\n<li>Time \u2013 display how long CPU time was given by kernel for that running process.<\/li>\n\n\n\n<li>COMMAND \u2013 the command that runs as a current process<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">03) Display all processes which be run by a command<\/h2>\n\n\n\n<p>To list all the processes which be run by a command, let\u2019s use the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -C &lt;command_name&gt;<\/code><\/pre>\n\n\n\n<p>For example, list all the processes of \u2018\/usr\/sbin\/kerneloops\u2019 command by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -C kerneloops<\/code><\/pre>\n\n\n\n<p>You may also use argument in the form of a blank-separated or comma-separated list, for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -C sshd,systemd<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">04) Display all processes which be run by a user<\/h2>\n\n\n\n<p>If you want to list the process by user whose user id 1000, let\u2019s run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -u 1000<\/code><\/pre>\n\n\n\n<p>You can also search process by username:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -U root -u root u<\/code><\/pre>\n\n\n\n<p>The&nbsp;<code>-U parameter<\/code>&nbsp;will select by&nbsp;<code>real user ID (RUID)<\/code>. It selects the processes whose real user name or ID is in the userlist list. The real User ID identifies the user who created the process.<\/p>\n\n\n\n<p>While the&nbsp;<code>-u paramater<\/code>&nbsp;will select by effective user ID (EUID)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">05) Display processes owned by group<\/h2>\n\n\n\n<p>In order to list all processes owned by a specific group name, let\u2019s run the command with&nbsp;<code>-fG<\/code>&nbsp;option. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -fG cas<\/code><\/pre>\n\n\n\n<p>In order to display all processes by group id, you can run the command with \u2018-g\u2019 option. For instance:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -g 1<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp; <code>&nbsp;PID TTY&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TIME CMD &nbsp;&nbsp; &nbsp; 1 ?&nbsp; &nbsp; &nbsp; &nbsp; 00:00:03 systemd<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">06) Display processes by PID<\/h2>\n\n\n\n<p>You can list all processes by PID by running the ps command with \u2018-fp\u2019 option. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -fp 34531<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UID &nbsp; &nbsp; &nbsp; &nbsp; PID &nbsp; PPID&nbsp; C STIME TTY&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TIME CMD cas &nbsp; &nbsp; &nbsp; 34531&nbsp; &nbsp; &nbsp; 1&nbsp; 0 06:16 ?&nbsp; &nbsp; &nbsp; &nbsp; 00:00:00 \/lib\/systemd\/systemd --user<\/code><\/pre>\n\n\n\n<p>Moreover, in order to list all processes by PPID, let\u2019s run the command with \u2018\u2013ppid\u2019 option:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -f --ppid 34529<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UID &nbsp; &nbsp; &nbsp; &nbsp; PID &nbsp; PPID&nbsp; C STIME TTY&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TIME CMD cas &nbsp; &nbsp; &nbsp; 34609&nbsp; 34529&nbsp; 0 06:16 ?&nbsp; &nbsp; &nbsp; &nbsp; 00:00:00 sshd: cas@pts\/0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">07) Display processes by TTY<\/h2>\n\n\n\n<p>In order to display all processes by TTY, you can run the command with \u2018-t\u2019 option. For instance:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -t tty1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">08) Display processes owned by current user<\/h2>\n\n\n\n<p>To list all processes are running by the current user, let\u2019s run the command with \u2018-x\u2019 option:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -x<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">09) Display all processes with full format listing<\/h2>\n\n\n\n<p>For instance, let\u2019s run the ps command with&nbsp;<code>-f<\/code>&nbsp;option, to display all process with the full format:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -af<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">10) Display all processes with extra format<\/h2>\n\n\n\n<p>Moreover, to view the extra full format listing of the result, run ps command with&nbsp;<code>-F<\/code>&nbsp;option. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -F<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">11) Display all processes in ASCII hierarchy format<\/h2>\n\n\n\n<p>To illustrate, assuming that you want to display all the process on your Linux system in ASCII art process hierarchy format, let\u2019s run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps af<\/code><\/pre>\n\n\n\n<p>The output will be in \u201cforest\u201d format:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">12) Display process in widen output<\/h2>\n\n\n\n<p>If you want to widen output when running the ps command, use&nbsp;<code>w<\/code>&nbsp;option:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps w<\/code><\/pre>\n\n\n\n<p>Let make a comparison between the outputs of running \u2018ps w\u2019 and \u2018ps\u2019:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">13) Display process according to user-defined format<\/h2>\n\n\n\n<p>You can use the following&nbsp; syntax to view in user-defined format:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Syntax: $ ps --format column_name $ ps -o column_name $ ps o column_name For example: $ ps -e -o user,pid,cmd<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">14) Display threads with thread id<\/h2>\n\n\n\n<p>For example, in order to show threads with SPID column (SPID is the thread id), run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -aT<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">15) Show the information about threads<\/h2>\n\n\n\n<p>Besides, you can use \u2018-L\u2019 option to get the information about threads in your Linux system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -aL<\/code><\/pre>\n\n\n\n<p>The output with \u2018LWP\u2019 column show you the thread id:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Some more examples<\/h2>\n\n\n\n<p><strong>01) Check which processes taking most RAM<\/strong><\/p>\n\n\n\n<p>The following command will display most memory using processes,&nbsp;<code>%MEM<\/code>&nbsp;in 1st column,&nbsp;<code>PID<\/code>&nbsp;in 2nd column and command in 3rd column for all running processes on the system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -eo pmem,pid,cmd | sort -k 1 -nr<\/code><\/pre>\n\n\n\n<p><strong>02) Displays all threads of a specific process id<\/strong><\/p>\n\n\n\n<p>This will show&nbsp;all the threads of a particular process pid.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -Lf -p 3482<\/code><\/pre>\n\n\n\n<p><strong>03) Shows child of a parent process<\/strong><\/p>\n\n\n\n<p>This will display all child processes of a process and is useful in finding out what processes have been forked out of this main process.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -o pid,pcpu,pmem,uname,comm -C apache2<\/code><\/pre>\n\n\n\n<p><strong>04) Displays how long process has been running<\/strong><\/p>\n\n\n\n<p>The following command will show how long the \u2018mysql\u2019 process has been running on the system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -e -o pid,comm,etime | grep mysql 3107 mysqld_safe 18-07:01:53 3469 mysqld 18-07:01:52<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>etime<\/code>: elapsed time since the process was started, in the form [[DD-]hh:]mm:ss.<\/li>\n\n\n\n<li><code>etimes<\/code>: elapsed time since the process was started, in seconds.<\/li>\n<\/ul>\n\n\n\n<p><strong>05) Get security information<\/strong><\/p>\n\n\n\n<p>If we want to see who is currently logged on into your server, we can see it using the ps command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -eo pid,user,args<\/code><\/pre>\n\n\n\n<p>Now you can map pids to their respective systemd units by below command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -e -o pid,unit,cmd<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The pstree (or use ps -axjf ) and pgrep are additional commands which can help get information about running process.<\/p>\n\n\n\n<p>You may use ps as real-time monitor using watch command, let say, we want to filter processes by CPU and Memory usage report is updated every 1 second.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ watch -n 1 \u2018ps -aux --sort -pmem, -pcpu\u2019<\/code><\/pre>\n\n\n\n<p>In this tutorial, we learned many ways to use the ps command in Linux. For exploring all options please refer ps man page.&nbsp;Thanks for reading and please leave your suggestion in the below comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The&nbsp;ps&nbsp;is a built-in command used in Unix\/Linux operating systems to list out the currently running processes. It displays a static snapshot with information about the processes whereas top, htop, and glances show repetitive updates. Ps command comes with lots of options to manipulate the outputs. It pulls all information of the processes from \/proc virtual filesystem. This tutorial will focus on explaining the way to use the ps command along with some practical examples The syntax of ps command The basic syntax for ps command usage is as follows: The \u2018options\u2019 of the ps command may be: This is a<\/p>\n","protected":false},"author":1,"featured_media":2018,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[26],"tags":[],"class_list":["post-2019","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/posts\/2019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/comments?post=2019"}],"version-history":[{"count":1,"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/posts\/2019\/revisions"}],"predecessor-version":[{"id":2205,"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/posts\/2019\/revisions\/2205"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/media\/2018"}],"wp:attachment":[{"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/media?parent=2019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/categories?post=2019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linoxide.com\/wp-json\/wp\/v2\/tags?post=2019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}