ps 命令:
执行man ps 命令,可以查询命令使用和描述
NAME
ps - report a snapshot of the current processes. (为展示打印当前进程快照)
携带参数linux常用命令,常用命令有:
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 -eopid,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 -p 42 -o comm=
lsof命令:
NAME
lsof - list open files (列出打开的文件)
直接lsof 打开的命令显示如下:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
init 1 root cwd dir 104,2 4096 2 /。init 1 root rtd dir 104,2 4096 2 /。crontab 20641 root cwd dir 253,0 4096 130818 /root。
init 1 root rtd DIR 253,0 4096 2 /
init 1 root txt REG 253,0 43496 524298 /sbin/init
crontab 20641 root mem reg 253,0 65928 261663 /lib64/libnss_files-2.12.so。crontab 20641 root mem reg 253,0 113432 261657 /lib64/libnsl-2.12.so。crontab 20641 root mem reg 253,0 99158576 397021 /usr/lib/locale/locale-archive。