简介
说明
本文用示例介绍Linux中查看进程的命令:pstree的用法。
格式
pstree [-acglpsStuZ] [-h|-H PID] [-n|-N type] [-A|-G|-U] [PID|USER]
PID start at this PID; default is 1 (init)
USER show only trees rooted at processes of this user
示例
命令 | 作用 |
ps -up | 打印所有进程(包括进程号和用户名) |
pstree -p pid | 打印pid的进程数 |
pstree -p `ps -e | grep java | awk '{print $1}'` | wc -l 或pstree -p pid | wc -l | 查找java的进程数 |
pstree -p | wc -l | 查询当前整个系统已用的进程数 |
选项
参数 | 含义 |
-a, --arguments | show command line arguments |
-A, --ascii | use ASCII line drawing characters |
-c, --compact | don't compact identical subtrees |
-h, --highlight-all | highlight current process and its ancestors |
-H PID, | |
--highlight-pid=PID | highlight this process and its ancestors |
-g, --show-pgids | show process group ids; implies -c |
-G, --vt100 | use VT100 line drawing characters |
-l, --long | don't truncate long lines |
-n, --numeric-sort | sort output by PID |
-N type, | |
--ns-sort=type | sort by namespace type (cgroup, ipc, mnt, net, pid, user, uts) |
-p, --show-pids | show PIDs; implies -c |
-s, --show-parents | show parents of the selected process |
-S, --ns-changes | show namespace transitions |
-t, --thread-names | show full thread names |
-T, --hide-threads | hide threads, show only processes |
-u, --uid-changes | show uid transitions |
-U, --unicode | use UTF-8 (Unicode) line drawing characters |
-V, --version | display version information |
-Z, --security-context | show SELinux security contexts |