https://blog.csdn.net/yspg_217/article/details/121845366
https://blog.csdn.net/qq_44681788/article/details/130902259
https://www.zhihu.com/question/378345922/answer/2871122003?utm_id=0
目录
参数说明
https://download.csdn.net/blog/column/12529139/135104281
https://www.cnblogs.com/zypdbk/p/16307104.html
linux版本
root@xinyi-virtual-machine:~# ps --help all
用法:
ps [选项]
基本选项:
-A, -e all processes
-a all with tty, except session leaders
a all with tty, including other users
-d all except session leaders
-N, --deselect negate selection
r only running processes
T all processes on this terminal
x processes without controlling ttys
Selection by list:
-C <命令> 命令名称
-G, --Group <GID> real group id or name
-g, --group <group> session or effective group name
-p, p, --pid <PID> 进程编号
--ppid <PID> 父进程编号
-q, q, --quick-pid <PID>
process id (quick mode)
-s, --sid <session> session id
-t, t, --tty <tty> 终端
-u, U, --user <UID> effective user id or name
-U, --User <UID> 真实用户编号或名称
The selection options take as their argument either:
a comma-separated list e.g. '-u root,nobody' or
a blank-separated list e.g. '-p 123 4567'
输出格式:
-F extra full
-f 完整格式,包含命令行
f, --forest ascii 字符艺术显示的进程树
-H show process hierarchy
-j jobs format
j BSD 任务控制格式
-l 长格式
l BSD 长格式
-M, Z 添加安全数据(用于 SELinux)
-O <format> preloaded with default columns
O <format> as -O, with BSD personality
-o, o, --format <格式>
用户定义的格式
s 信号格式
u user-oriented format
v 虚拟内存格式
X 寄存器格式
-y do not show flags, show rss vs. addr (used with -l)
--context 显示安全上下文(用于 SELinux)
--headers repeat header lines, one per page
--no-headers do not print header at all
--cols, --columns, --width <num>
set screen width
--rows, --lines <num>
set screen height
Show threads:
H as if they were processes
-L possibly with LWP and NLWP columns
-m, m after processes
-T possibly with SPID column
Miscellaneous options:
-c show scheduling class with -l option
c show true command name
e show the environment after command
k, --sort specify sort order as: [+|-]key[,[+|-]key[,...]]
L show format specifiers
n display numeric uid and wchan
S, --cumulative include some dead child process data
-y do not show flags, show rss (only with -l)
-V, V, --version display version information and exit
-w, w 不限制输出宽度
android版本
- 线程显示-T
注意linux显示线程是-L
实用场景
-
进程名称显示不全问题
ps w或者ps x -
查找进程的启动目录
1.pwdx 进程id
https://www.cnblogs.com/wangzy-Zj/p/12416278.html
2.ll /proc/进程id/cwd
https://www.cnblogs.com/wangzy-Zj/p/12416278.html
https://www.cnblogs.com/exception1/p/14665407.html -
打印进程号
ps -ef | grep "name" | grep -v grep | awk '{print $2}'
-
打印父进程号
ps axo pid,ppid | grep 1234 -
查看当前shell的进程
ps -p $$
-
查看文件被哪些进程占用
fuser
https://www.coonote.com/linux/linux-cmd-fuser.html -
查看进程的调用树图(查看子进程)
pstree -p 进程号 -
查看特定进程的SELinux上下文
ps -p PID -Z
0 条评论