PS – it's just like Top but shows more information
ps – Displays The Processes
ps command will report a snapshot of the current processes. To select all processes use the -A or -e option:
# ps -A
Sample Outputs:
ps -A
PID TTY TIME CMD
1 ttyp0 00:00:22 init
89 ? 00:00:00 init-logger
142 ? 00:00:00 udevd
634 ? 00:00:00 syslog-ng
635 ? 00:20:39 syslog-ng
718 ? 00:00:00 zabbix_agentd
720 ? 00:04:02 zabbix_agentd
736 ? 00:00:00 xinetd
754 ? 00:00:00 mysqld_safe
784 ? 21:08:05 mysqld
788 pts/2 00:00:00 zsh
820 ? 00:00:01 logger
826 ? 00:00:00 httpd
827 ? 00:00:34 httpd
1154 ? 00:00:00 gam_server
1633 ? 00:05:30 httpd
1642 ? 00:00:05 pure-ftpd
....
32656 ? 00:00:00 exim
32659 ? 00:00:02 php5
32660 ? 00:00:00 php5
32691 ? 00:00:00 gam_server
32698 ? 00:00:01 php5
32700 ? 00:00:00 php5
32704 ? 00:00:00 exim
32705 ? 00:00:00 cpsrvd-ssl
32707 pts/0 00:00:00 ps
Now for some switches that will allow you to do a lot more with this command:
Show Long Format Output
# ps -Al
To turn on extra full mode (it will show command line arguments passed to process):
# ps -AlF
To See Threads ( LWP and NLWP)
# ps -AlFH
To See Threads After Processes
# ps -AlLm
Print All Process On The Server
# ps ax
# ps axu
Print A Process Tree
# ps -ejH
# ps axjf
# pstree
Print Security Information
# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps -eM
See Every Process Running As User Vivek
# ps -U vivek -u vivek u
Set Output In 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
Display Only The Process IDs of httpd (apache)
# ps -C httpd -o pid=
OR
# pgrep httpd
OR
# pgrep -u vivek php-cgi
Display The Name of PID 58721
# ps -p 58721 -o comm=
Find Out The Top 10 Memory Consuming Process
# ps -auxf | sort -nr -k 4 | head -10
Find Out top 10 CPU Consuming Process
# ps -auxf | sort -nr -k 3 | head -10
Finally – when in doubt – consult the man page…
Mix it up a little and do some testing – I promise this will become a best friend in your arsenal.
Pages
Tags
apple Archived asperger's autism blogging cat6 Chatter Church cisco citrt comcast convention cPanel datacenter debugging mysql devil evangelism facebook faith family iPad iPhone iscsi Leadership Linux MAC Marketing Microsoft MySQL network Off the wall crazy OpenSource or just weirdly different pfsense politics Ramblings review Security skype Sprint Storage Technology Web 2.0 minus or plus Wifi wisp

