linux下ps命令小技巧
ps【process status】显示进程的快照
显示系统运行的全部进程
ps aux
显示进程树,各进程的依赖关系
ps axuf
ps –ejH
例:
jboss 15022 0.0 0.0 4428 1040 ? S 12:10 0:00 /bin/sh /usr/local/jboss/bin/run.sh
jboss 15046 1.1 10.2 1409376 420432 ? Sl 12:10 3:37 \_ /usr/jdk1.5.0_09/bin/java -Dprogram.name=run.sh -server -Xms256m -Xmx512m -XX:PermSize=256m
root 1067 0.0 0.0 7436 3508 ? Ss Mar05 0:00 /usr/local/apache2/bin/httpd -k start
nobody 14854 0.0 0.0 7848 3596 ? S 11:54 0:00 \_ /usr/local/apache2/bin/httpd -k start
nobody 14855 0.0 0.0 7724 3584 ? S 11:54 0:00 \_ /usr/local/apache2/bin/httpd -k start
nobody 14856 0.0 0.0 7688 3452 ? S 11:54 0:00 \_ /usr/local/apache2/bin/httpd -k start
nobody 14857 0.0 0.0 7688 3556 ? S 11:54 0:00 \_ /usr/local/apache2/bin/httpd -k start
显示特定用户的进程
ps U user
例:
~ # ps U oracle
PID TTY STAT TIME COMMAND
3322 ? Ssl 0:31 /home/oracle/product/10.1.0/db_1/bin/tnslsnr LISTENER -inherit
3328 ? Ss 0:00 ora_pmon_oinstall
3330 ? Ss 0:00 ora_psp0_oinstall
3332 ? Ss 0:00 ora_mman_oinstall
3334 ? Ss 0:34 ora_dbw0_oinstall
3336 ? Ss 1:26 ora_lgwr_oinstall
3338 ? Ss 6:41 ora_ckpt_oinstall
3340 ? Ss 0:39 ora_smon_oinstall
3342 ? Ss 0:00 ora_reco_oinstall
3344 ? Ss 0:18 ora_cjq0_oinstall
显示当前用户的进程
ps U $USER
其实一切都在ps --help里
~ # ps --help
********* simple selection ********* ********* selection by list *********
-A all processes -C by command name
-N negate selection -G by real group ID (supports names)
-a all w/ tty except session leaders -U by real user ID (supports names)
-d all except session leaders -g by session OR by effective group name
-e all processes -p by process ID
T all processes on this terminal -s processes in the sessions given
a all w/ tty, including other users -t by tty
g OBSOLETE -- DO NOT USE -u by effective user ID (supports names)
r only running processes U processes for specified users
x processes w/o controlling ttys t by tty
*********** output format ********** *********** long options ***********
-o,o user-defined -f full --Group --User --pid --cols --ppid
-j,j job control s signal --group --user --sid --rows --info
-O,O preloaded -o v virtual memory --cumulative --format --deselect
-l,l long u user-oriented --sort --tty --forest --version
-F extra full X registers --heading --no-heading --context
********* misc options *********
-V,V show version L list format codes f ASCII art forest
-m,m,-L,-T,H threads S children in sum -y change -l format
-M,Z security data c true command name -c scheduling class
-w,w wide output n numeric WCHAN,UID -H process hierarchy
ref:
http://www.thegeekstuff.com/linux-101-hacks-free-ebook/
没有评论:
发表评论