Unix / Linux: Find Information About The Process Including All Command Line Parameters

by on March 28, 2012 · 0 comments· LAST UPDATED March 28, 2012

in ,

I'm using ps command to read a snapshot of the current processes under Unix / Linux operating systems. However, ps -e or ps aux only displays command / processes names. I need to see complete information about the process including all parameters passed to it. How do I see it under Unix / Linux using ps command?

To see every process on the Unix like system use the following standard syntax:

 
ps -e
ps -ef
ps -eF
ps -ely
ps axu
 

Sample outputs:

UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
root         1     0  0  2101   792   6 11:17 ?        00:00:02 init [2]
root         2     0  0     0     0   1 11:17 ?        00:00:00 [kthreadd]
root         3     2  0     0     0   0 11:17 ?        00:00:00 [ksoftirqd/0]
root         6     2  0     0     0   0 11:17 ?        00:00:00 [migration/0]
root         7     2  0     0     0   0 11:17 ?        00:00:00 [watchdog/0]
root         8     2  0     0     0   1 11:17 ?        00:00:00 [migration/1]
root        10     2  0     0     0   1 11:17 ?        00:00:00 [ksoftirqd/1]
root        12     2  0     0     0   1 11:17 ?        00:00:00 [watchdog/1]
root        13     2  0     0     0   2 11:17 ?        00:00:00 [migration/2]
root        15     2  0     0     0   2 11:17 ?        00:00:00 [ksoftirqd/2]
....
....
..
vivek     3633  2901  0 223266 82628  5 11:43 ?        00:00:01 /opt/google/chrome/chrome --type=renderer --lang=en-US --force-fieldtest=CacheListSize/CacheLi
vivek     3641  3005  0  5563  5028   0 11:43 pts/2    00:00:00 bash
root      3756     2  0     0     0   4 11:44 ?        00:00:00 [kworker/4:2]
root      3757     2  0     0     0   6 11:44 ?        00:00:02 [kworker/6:0]
root      3781     2  0     0     0   0 11:46 ?        00:00:00 [kworker/0:0]
root      3789     2  0     0     0   3 11:46 ?        00:00:00 [kworker/3:0]
root      3994     2  0     0     0   2 11:48 ?        00:00:00 [kworker/2:0]

However, this will not display all command line args passed to the command due to screen size limitations. You need to add 'ww' after aux, as follows for complete information about the process including all command line parameters:

 
ps auxww
 

Sample outputs:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.1  0.0   8404   792 ?        Ss   11:17   0:02 init [2]
root         2  0.0  0.0      0     0 ?        S    11:17   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    11:17   0:00 [ksoftirqd/0]
root         6  0.0  0.0      0     0 ?        S    11:17   0:00 [migration/0]
root         7  0.0  0.0      0     0 ?        S    11:17   0:00 [watchdog/0]
root         8  0.0  0.0      0     0 ?        S    11:17   0:00 [migration/1]
root        10  0.0  0.0      0     0 ?        S    11:17   0:00 [ksoftirqd/1]
root        12  0.0  0.0      0     0 ?        S    11:17   0:00 [watchdog/1]
root        13  0.0  0.0      0     0 ?        S    11:17   0:00 [migration/2]
....
.....
..
root      1705  0.0  0.0  70340  4200 ?        Ss   11:19   0:00 /usr/sbin/NetworkManager
root      1711  0.0  0.0  59936  2524 ?        S    11:19   0:00 /usr/sbin/modem-manager
bind      1713  0.0  0.4 256904 32532 ?        Ssl  11:19   0:01 /usr/sbin/named -u bind
root      1755  0.0  0.0  28312  1976 ?        S    11:19   0:00 /sbin/wpa_supplicant -u -s
root      1758  0.0  0.0  24340  1168 ?        S    11:19   0:00 hald-addon-input: Listening on /dev/input/event17 /dev/input/event10 /dev/input/event0 /dev/input/event4 /dev/input/event3 /dev/input/event1 /dev/input/event7 /dev/input/event6 /dev/input/event8 /dev/input/event5 /dev/input/event15
root      1767  0.0  0.0  24332  1168 ?        S    11:19   0:00 /usr/lib/hal/hald-addon-generic-backlight
root      1768  0.0  0.0  24332  1168 ?        S    11:19   0:00 /usr/lib/hal/hald-addon-rfkill-killswitch
www-data  1782  0.0  0.0  58156  1352 ?        S    11:19   0:00 /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
www-data  1790  0.0  0.0  92828  7568 ?        Ss   11:19   0:00 /usr/bin/php-cgi
root      1795  0.0  0.0  24336  1396 ?        S    11:19   0:00 hald-addon-storage: polling /dev/sr0 (every 2 sec)
root      1801  0.0  0.0  24348  1172 ?        S    11:19   0:00 /usr/lib/hal/hald-addon-cpufreq
111       1802  0.0  0.0  26156  1236 ?        S    11:19   0:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
root      1815  0.0  0.0   4004   624 ?        S    11:19   0:00 /bin/sh /usr/bin/mysqld_safe
www-data  1937  0.0  0.0  92828  3224 ?        S    11:19   0:00 /usr/bin/php-cgi
www-data  1938  0.0  0.0  92828  3224 ?        S    11:19   0:00 /usr/bin/php-cgi
www-data  1939  0.0  0.0  92828  3224 ?        S    11:19   0:00 /usr/bin/php-cgi
www-data  1940  0.0  0.0  92828  3224 ?        S    11:19   0:00 /usr/bin/php-cgi
mysql     1942  0.0  0.4 172232 33108 ?        Sl   11:19   0:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
root      1943  0.0  0.0   3904   588 ?        S    11:19   0:00 logger -t mysqld -p daemon.error
root      2008  0.0  0.0      0     0 ?        S    11:19   0:00 [kworker/1:2]
root      2083  0.0  0.0  74304  2992 ?        Sl   11:19   0:00 /usr/sbin/gdm3
root      2096  0.0  0.0  99764  4264 ?        Sl   11:19   0:00 /usr/lib/gdm3/gdm-simple-slave --display-id /org/gnome/DisplayManager/Display1
root      2106  2.5  2.7 313204 222816 tty7    Ss+  11:19   0:52 /usr/bin/Xorg :0 -br -verbose -audit 0 -novtswitch -auth /var/run/gdm3/auth-for-Debian-gdm-sioDyr/database -nolisten tcp vt7

The -w option is for wide output. Use this option twice for unlimited width. You can use shell pipes to filter output as follows:
$ ps auxww | grep pid
$ ps auxww | grep mysqld
$ ps auxww | grep --color mysqld

Sample outputs:

Fig.01: ps auxww in Action ( click to enlarge )

Fig.01: ps auxww in Action ( click to enlarge )

Controlling ps Output

The -o option to ps command can be used to see ouput in user-defined format. In this example, 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
 

You can only see PID, command and its args using the following format:

 
ps axo pid,command,args
 

Sample outputs:

Unix / Linux ps command output format control command

Fig.02: Unix / Linux ps command output format control command

A Note About Default Output Format

Set PS_FORMAT shell variable to override default output format. You may set this to a format string of the type used for the -o option.

 
export PS_FORMAT=pid,command,args
ps auxww
 
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 0 comments… add one now }

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: