wannagonna 2020-03-07
给出实验环境:
运行man ps
,将ps
使用方法拷贝过来,比如:
SYNOPSIS ps [options] EXAMPLES To see every process on the system using standard syntax: ps -e ps -ef ps -eF ps -ely To see every process on the system using BSD syntax: ps ax ps axu To print a process tree: ps -ejH ps axjf To get info about threads: ps -eLf ps axms To get security info: ps -eo euser,ruser,suser,fuser,f,comm,label ps axZ ps -eM To see every process running as root (real & effective ID) in user format: ps -U root -u root u To 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 -Ao pid,tt,user,fname,tmout,f,wchan Print only the process IDs of syslogd: ps -C syslogd -o pid= Print only the name of PID 42: ps -q 42 -o comm=
(1)运行
ps -ef,
系统的返回结果:
UID PID PPID C STIME TTY TIME CMD root 1 0 0 3月06 ? 00:00:11 /sbin/init splash root 2 0 0 3月06 ? 00:00:00 [kthreadd] root 3 2 0 3月06 ? 00:00:00 [rcu_gp] root 4 2 0 3月06 ? 00:00:00 [rcu_par_gp] root 6 2 0 3月06 ? 00:00:00 [kworker/0:0H-kb]
UID : 用户的ID PID : 进程标识符 PPID :父进程标识符 C :CPU占用的百分比 STIME :进程开始的时间 TTY :登入者的终端机位置 TIME :使用掉的CPU时间CMD :所下达的指令为啥(2)运行ps -ely,系统的返回结果:
:/home/zouwenbin# ps -ely S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD S 0 1 0 0 80 0 9448 56426 ep_pol ? 00:00:17 systemd S 0 2 0 0 80 0 0 0 kthrea ? 00:00:00 kthreadd I 0 3 2 0 60 -20 0 0 rescue ? 00:00:00 rcu_gp I 0 4 2 0 60 -20 0 0 rescue ? 00:00:00 rcu_par_gp I 0 6 2 0 60 -20 0 0 worker ? 00:00:00 kworker/0:0H-kb
解释命令中参数的含义: