歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

ps命令常用參數

ps命令常用參數   一直都用ps命令,但是很少去琢磨其中參數的含義,很多人都和我一樣吧. 今天花點時間看一下, 首先是我常用的命令 [plain]  ps -def     -d Select all processes except session leaders. 什麼是session leader。 [plain]  Every process group is in a unique session. (When the process is created, it becomes a member of the session of its parent.) By convention, the session ID of a session equals the process ID of the first member of the session, called the session leader. A process finds the ID of its session using the system call getsid().      Every session may have a controlling tty, that then also is called the controlling tty of each of its member processes. A file descriptor for the controlling tty is obtained by opening /dev/tty. (And when that fails, there was no controlling tty.) Given a file descriptor for the controlling tty, one may obtain the SID using tcgetsid(fd).      A session is often set up by a login process. The terminal on which one is logged in then becomes the controlling tty of the session. All processes that are descendants of the login process will in general be members of the session.     進程是按照進程組管理的,進程組又屬於session。關系如下: 每個session擁有一個或者多個進程組,每個進程組擁有一個或多個進程。第一個屬於某個session的進程id就是這個session的 leader, session id就用它的進程id。 和進程相關的id有幾種, 進程id, 父進程id, 進程組id 和 session id.   -e 參數等同於 -A, [plain]  -e     Select all processes.  Identical to -A.     -f 參數 顯示完整格式 [plain]  -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 參數 [plain]  -a     Select all processes except both session leaders (see getsid(2)) and processes not associated with a terminal.   -x 參數 和tty有關,tty會在另一篇文章中解釋 [plain]  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 參數 [plain]  -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參數,比如 [plain]  $ UNIX95= ps -C nginx     PID TTY          TIME CMD    1258 ?        00:00:00 nginx    1259 ?        00:00:00 nginx   CHN\shu6889@sloop2:~$ ps aux | grep nginx   root      1258  0.0  0.0  31188  1028 ?        Ss   09:24   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf   root      1259  0.0  0.0  47312  2708 ?        S    09:24   0:00 nginx: worker process                      70780027  4336  0.0  0.0  13652   976 pts/1    S+   10:40   0:00 grep --color=auto nginx     要注意,前面需要輸入UNIX95=
Copyright © Linux教程網 All Rights Reserved