一天一个shell命令 linux好管家-进程-ps命令详解

2019-09-23 09:19:05王冬梅

 -C by command name
 -G by real group ID (supports names)
 -U by real user ID (supports names)
 -g by session OR by effective group name
 -p by process ID
 -s processes in the sessions given
 -t by tty
 -u by effective user ID (supports names)
 U  processes for specified users
 t  by tty

output format  输出格式化

*********** output format ********** 
 -o,o user-defined   可以输入自己的参数
-f full          
 -j,j job control 
 s  signal         
 -O,O preloaded
 -o  v  virtual memory 
 -l,l long        
 u  user-oriented  
 -F   extra full  
 X  registers  

long options  长操作类型

*********** long options ***********
 --Group  --User  --pid  --cols  --ppid
 --group  --user  --sid  --rows  --info
 --cumulative  --format  --deselect
 --sort  --tty  --forest  --version
 --heading  --no-heading  --context

misc options 其他选项

********* 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


实例(来自man ps)

1. 查看系统每个进程的标准参数(To see every process on the system using standard syntax)

$ps -e    
$ps -ef  
$ps -eF  
$ps –ely

2. 查看系统每个进程的BSD(系统名)参数(To see every process on the system using BSD syntax)


$ps ax  
$ps axu

3. 打印进程树(To print a process tree)

$ps -ejH  
$ps axjf

4. 打印线程的有关信息

$ps -eLf  
$ps axms

5. 获取安全信息

$ps -eo euser,ruser,suser,fuser,f,comm,label  
$ps axZ  
$ps –eM

6. 要查看每个进程运行在用户根目录(真实的和有效的ID)格式

$ps -U root -u root u

7. 查看用户自定义的格式(To see every process with a user-defined format)