本节内容:
linuxjishu/14079.html target=_blank class=infotextkey>ps命令常用参数
一直都用ps命令,但是很少去琢磨其中参数的含义,今天分享一些ps命令的常用参数,供大家参考。
我的常用命令:
什么是session leader。
参考该解释:http://www.win.tue.nl/~aeb/linux/lk/lk-10.html#ss10.3
进程是按照进程组管理的,进程组又属于session。
关系如下:
每个session拥有一个或者多个进程组,每个进程组拥有一个或多个进程。
第一个属于某个session的进程id就是这个session的 leader, session id就用它的进程id。
和进程相关的id有几种,进程id, 父进程id, 进程组id 和 session id.
参考:http://unix.stackexchange.com/questions/18166/what-are-session-leaders-in-ps
-e 参数等同于 -A,
[plain] view plaincopyprint?
-e Select all processes. Identical to -A.
-f 参数 显示完整格式
[plain] view plaincopyprint?
-f Do full-format listing. This option can be combined with many other UNIX-style options to add additional columns. It also causes the command arguments to be
printed. When used with -L, the NLWP (number of threads) and LWP (thread ID) columns will be added. See the c option, the format keyword args, and the
format keyword comm.
不过还有个常用的方式:
ps axu
不同于ps -def 用标准风格,这是BSD风格(不用-作为引导参数), BSD风格会在另一篇博客中介绍。
-a 参数
-a Select all processes except both session leaders (see getsid(2)) and processes not associated with a terminal.
-x 参数 和tty有关,tty会在另一篇文章中解释
x Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when
the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An
alternate description is that this option causes ps to list all processes owned by you (same EUID as ps), or to list all processes when used together with the
a option.
-u 参数
-u userlist
Select by effective user ID (EUID) or name. This selects the processes whose effective user name or ID is in userlist.
The effective user ID describes the user whose file access permissions are used by the process (see geteuid(2)). Identical to U and --user.
还有一种,通过直接输入命令查找,用-C参数,比如:
注意,前面需要输入UNIX95=。
相关阅读:linux命令实例教程,大家可以深入学习下常用的linux命令。