⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ps.1

📁 linux下获取一些环境信息的代码
💻 1
📖 第 1 页 / 共 3 页
字号:
'\" t.\" (The preceding line is a note to broken versions of man to tell.\" Man page for ps..\" Quick hack conversion by Albert Cahalan, 1998..\" Licensed under version 2 of the Gnu General Public License..\".TH PS 1 "July 28, 2004" "Linux" "Linux User's Manual".\".\" To render this page:.\"    groff -t -b -man -X -P-resolution -P100 -Tps ps.1 &.\"    groff -t -b -man -X -TX100 ps.1 &.\"    tbl ps.1 | troff -Ww -man -z.\"    groff -t -man -Tps ps.1 | ps2pdf - - > ps.pdf.\".\" The '70s called. They want their perfect justification,.\" hyphenation, and double-spaced sentences back..na.nh.if n .ss 12 0.\".\" See /usr/share/groff/current/tmac/an-old.tmac for what these do..\" Setting them to zero provides extra space, but only do that for.\" plain text output. PostScript and such will remain indented..if n .nr IN 0n.if n .nr an-prevailing-indent 0n.\".\".\" ColSize is used for the format spec table..\" It's the left margin, minus the right, minus.\" the space needed for the 1st two columns..\" Making it messy: inches, ens, points, scaled points....\".nr ColSize ((\n(.lu-\n(.iu/\n(.Hu-20u)n).\".\" This is for command options.nr OptSize (16u).\".\" l=\n(.l.\" i=\n(.i.\" o=\n(.o.\" H=\n(.H.\" s=\n(.s.\" ColSize=\n[ColSize].\" .\" Macro for easy option formatting:   .opt \-x.de opt              .  TP \\n[OptSize].  BI \\$*...\".SH NAMEps \- report a snapshot of the current processes..SH SYNOPSIS\fBps\fR [\fIoptions\fR].PP.PP.SH DESCRIPTION.B psdisplays information about a selection of the active processes.If you want a repetitive update of the selection and thedisplayed information, use\ \fItop\fR(1) instead..PThis version of \fBps\fR accepts several kinds of options:.PD 0.IP 1 4UNIX options, which may be grouped and must be preceded by a dash..IP 2 4BSD options, which may be grouped and must not be used with a dash..IP 3 4GNU long options, which are preceded by two dashes..PD.PPOptions of different types may be freely mixed, but conflicts can appear.There are some synonymous options, which are functionally identical, dueto the many standards and \fBps\fR implementations that this \fBps\fR iscompatible with..PNote that "\fBps\ \-aux\fR" is distinct from "\fBps\ aux\fR".The POSIX and UNIX standards require that "\fBps\ \-aux\fR" print allprocesses owned by a user named "x", as well as printing all processesthat would be selected by the \fB\-a\fR option. If the user named "x" doesnot exist, this \fBps\fR may interpret the command as "\fBps\ aux\fR"instead and print a warning. This behavior is intended to aid intransitioning old scripts and habits. It is fragile, subject to change,and thus should not be relied upon..PBy default, \fBps\fR selects all processeswith the same effective user ID (euid=EUID) as the current userandassociated with the same terminal as the invoker.It displays the process ID (pid=PID),the terminal associated with the process (tname=TTY),the cumulated CPU time in [dd\-]hh:mm:ss format (time=TIME),and the executable name (ucmd=CMD).Output is unsorted by default..PThe use of BSD\-style options will add process state (stat=STAT) to thedefault display and show the command args (args=COMMAND) instead of theexecutable name. You can override this with the \fBPS_FORMAT\fRenvironment variable. The use of BSD\-style options will also change theprocess selection to include processes on other terminals (TTYs) thatare owned by you; alternately, this may be described as setting theselection to be the set of all processes filtered to excludeprocesses owned by other users or not on a terminal. These effectsare not considered when options are described as being "identical" below,so \fB\-M\fR will be considered identical to \fBZ\fR and so on..PExcept as described below, process selection options are additive.The default selection is discarded, and then the selected processesare added to the set of processes to be displayed.A\ process will thus be shown if it meets any of the givenselection criteria..PP.\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""".SH "EXAMPLES".TP 3To see every process on the system using standard syntax:.B ps\ \-e.br.B ps\ \-ef.br.B ps\ \-eF.br.B ps\ \-ely.TPTo see every process on the system using BSD syntax:.B ps\ ax.br.B ps\ axu.TPTo print a process tree:.B ps\ -ejH.br.B ps\ axjf.TPTo get info about threads:.B ps\ -eLf.br.B ps\ axms.TPTo get security info:.B ps\ -eo euser,ruser,suser,fuser,f,comm,label.br.B ps\ axZ.br.B ps\ -eM.TPTo see every process running as root (real\ &\ effective\ ID) in user format:.B ps\ \-U\ root\ \-u\ root\ u.TPTo see every process with a user\-defined format:.B ps\ \-eo\ pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm.br.B ps\ axo\ stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm.br.B ps\ \-eopid,tt,user,fname,tmout,f,wchan.TPPrint only the process IDs of syslogd:.B ps\ \-C\ syslogd\ \-o\ pid=.TPPrint only the name of PID 42:.B ps\ \-p\ 42\ \-o\ comm=.PP.PP.\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""".SH "SIMPLE PROCESS SELECTION".opt \-ASelect all processes.  Identical to \fB\-e\fR..opt \-NSelect all processes except those that fulfill the specified conditions.(negates the selection) Identical to \fB\-\-deselect\fR..opt TSelect all processes associated with this terminal.  Identical to the\fBt\fR option without any argument..opt \-aSelect all processes except session leaders (see \fIgetsid\fR(2)) andprocesses not associated with a terminal..opt aLift the BSD\-style "only yourself" restriction, which is imposed uponthe set of all processes when some BSD\-style (without\ "\-") optionsare used or when the \fBps\fR personality setting is BSD\-like.The set of processes selected in this manner isin addition to the set of processes selected by other means.An alternate description is that this option causes \fBps\fR tolist all processes with a terminal (tty),or to list all processes when used together with the \fBx\fR option..opt \-dSelect all processes except session leaders..opt \-eSelect all processes.  Identical to \fB\-A\fR..\" Current "g" behavior: add in the session leaders, which would.\" be excluded in the sunos4 personality. Supposed "g" behavior:.\" add in the group leaders -- at least according to the SunOS 4.\" man page on the FreeBSD site. Uh oh. I think I had tested SunOS.\" though, so maybe the code is correct..opt gReally all, even session leaders.  This flag is obsolete and may bediscontinued in a future release. It is normally implied by the \fBa\fR flag,and is only useful when operating in the sunos4 personality..opt rRestrict the selection to only running processes..opt xLift the BSD\-style "must have a tty" restriction, which is imposed uponthe set of all processes when some BSD\-style (without\ "\-") optionsare used or when the \fBps\fR personality setting is BSD\-like.The set of processes selected in this manner isin addition to the set of processes selected by other means.An alternate description is that this option causes \fBps\fR tolist all processes owned by you (same EUID as \fBps\fR),or to list all processes when used together with the \fBa\fR option..opt \-\-deselectSelect all processes except those that fulfill the specified conditions.(negates the selection) Identical to \fB\-N\fR..\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""".PD.PP.SH "PROCESS SELECTION BY LIST"These options accept a single argument in the form of a blank\-separatedor comma\-separated list.  They can be used multiple times.For\ example:\ \fBps\ \-p\ "1\ 2"\ \-p\ 3,4\fR.P.opt \-C \ cmdlistSelect by command name..brThis selects the processes whose executable name is given in\fIcmdlist\fR..opt \-G \ grplistSelect by real group ID (RGID) or name..brThis selects the processes whose real group name or ID is in the\fIgrplist\fR list.  The real group ID identifies the group of the userwho created the process, see \fIgetgid\fR(2)..opt U \ userlistSelect by effective user ID (EUID) or name..brThis selects the processes whose effective user nameor ID is in \fIuserlist\fR.The effective user\ ID describes the user whose fileaccess permissions are used by the process(see\ \fIgeteuid\fR(2)).Identical to \fB\-u\fR and\ \fB\-\-user\fR..opt \-U \ userlistselect by real user ID (RUID) or name..brIt selects the processes whose real user name or ID is in the\fIuserlist\fR list.The real user ID identifies the user who created the process,see\ \fIgetuid\fR(2)..opt \-g \ grplistSelect by session OR by effective group name..brSelection by session is specified by many standards,but selection by effective group is the logical behavior thatseveral other operating systems use.This \fBps\fR will select by session when the listis completely numeric (as\ sessions\ are).Group ID numbers will work only when some group names are also specified.See the \fB\-s\fR and \fB\-\-group\fR options..opt p \ pidlistSelect by process ID.  Identical to \fB\-p\fR and\ \fB\-\-pid\fR..opt \-p \ pidlistSelect by PID..brThis selects the processes whose process ID numbers appear in\fIpidlist\fR.  Identical to \fBp\fR and\ \fB\-\-pid\fR..opt \-s \ sesslistSelect by session ID..brThis selects the processeswith a session ID specified in\ \fIsesslist\fR..opt t \ ttylistSelect by tty.  Nearly identical to \fB\-t\fR and \fB\-\-tty\fR,but can also be used with an empty \fIttylist\fR to indicatethe terminal associated with \fBps\fR.Using the \fBT\fR option is considered cleaner than using \fBT\fR withan\ empty\ \fIttylist\fR..opt \-t \ ttylistSelect by tty..brThis selects the processes associated with the terminalsgiven in \fIttylist\fR.Terminals (ttys, or screens for text output) can be specified in severalforms: /dev/ttyS1, ttyS1, S1.A\ plain "\-" may be used to select processes not attached to any terminal..opt \-u \ userlistSelect by effective user ID (EUID) or name..brThis selects the processes whose effective user name or ID is in\fIuserlist\fR.  The effective user ID describes the user whose fileaccess permissions are used by the process (see\ \fIgeteuid\fR(2)).Identical to \fBU\fR and \fB\-\-user\fR..opt \-\-Group \ grplistSelect by real group ID (RGID) or name.  Identical to \fB\-G\fR..opt \-\-User \ userlistSelect by real user ID (RUID) or name.  Identical to \fB\-U\fR..opt \-\-group \ grplistSelect by effective group ID (EGID) or name..brThis selects the processes whose effective group name or ID is in\fIgrouplist\fR.  The effective group ID describes the group whose fileaccess permissions are used by the process (see\ \fIgeteuid\fR(2)).The \fB\-g\fR option is often an alternative to\ \fB\-\-group\fR..opt \-\-pid \ pidlistSelect by process\ ID.  Identical to \fB\-p\fR\ and\ \fBp\fR..opt \-\-ppid \ pidlistSelect by parent process\ ID.This selects the processeswith a parent\ process\ ID in \fRpidlist\fR.That\ is, it selects processes that are childrenof those listed in \fRpidlist\fR..opt \-\-sid \ sesslistSelect by session\ ID.  Identical to\ \fB\-s\fR..opt \-\-tty \ ttylistSelect by terminal.  Identical to \fB\-t\fR and\ \fBt\fR..opt \-\-user \ userlistSelect by effective user ID (EUID) or name.Identical to \fB\-u\fR and\ \fBU\fR..opt \-\fI123\fRIdentical to \fB\-\-sid\ \fI123\fR..opt \fI123\fRIdentical to \fB\-\-pid\ \fI123\fR..\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""".PD.PP.SH "OUTPUT FORMAT CONTROL"These options are used to choose the information displayed by \fBps\fR.The output may differ by personality..PP.opt \-Fextra full format. See the \fB\-f\fR option, which \fB\-F\fR implies..opt \-O \ formatis like \fB\-o\fR, but preloaded with some default columns.Identical to \fB\-o\ pid,\fIformat\fB,state,tname,time,command\fRor \fB\-o\ pid,\fIformat\fB,tname,time,cmd\fR, see\ \fB\-o\fR\ below..opt O \ formatis preloaded \fBo\fR (overloaded)..brThe BSD \fBO\fR option can act like \fB\-O\fR (user\-defined outputformat with some common fields predefined) or can be used to specifysort order.  Heuristics are used to determine the behavior of thisoption. To ensure that the desired behavior is obtained (sorting orformatting), specify the option in some other way(e.g. with \fB\-O\fR or \fB\-\-sort\fR).When used as a formatting option, it is identical to \fB\-O\fR, with theBSD\ personality..opt \-MAdd a column of security data. Identical to \fBZ\fR. (for\ SE\ Linux).opt XRegister format..opt ZAdd a column of security data. Identical to \fB\-M\fR. (for\ SE\ Linux).opt \-cShow different scheduler information for the \fB\-l\fR option..opt \-fdoes full\-format listing. This option can be combined with manyother UNIX\-style options to add additional columns. It also causesthe command arguments to be printed. When used with \fB\-L\fR, theNLWP (number of threads) and LWP (thread ID) columns will be added.See the \fBc\fR option, the format keyword \fBargs\fR, and theformat keyword \fBcomm\fR..opt jBSD job control format..opt \-jjobs format.opt ldisplay BSD long format..opt \-llong format. The \fB\-y\fR option is often useful with this..opt o \ formatspecify user\-defined format.  Identical to \fB\-o\fR and\fB\-\-format\fR..opt \-o \ formatuser\-defined format..br\fIformat\fR is a single argument in the form of ablank\-separated or comma\-separated list, which offersa way to specify individual output columns.The recognized keywords are described in the \fBSTANDARD FORMATSPECIFIERS\fR section below.Headers may berenamed (\fBps\ \-o\ pid,ruser=RealUser\ \-o\ comm=Command\fR) as desired.If all column headers are empty (\fBps\ \-o\ pid=\ \-o\ comm=\fR) then theheader line will not be output. Column width will increase asneeded for wide headers; this may be used to widen up columnssuch as WCHAN (\fBps\ \-o\ pid,wchan=WIDE\-WCHAN\-COLUMN\ \-o\ comm\fR).Explicit width control (\fBps\ opid,wchan:42,cmd\fR) is offered too.The behavior of \fBps\ \-o\ pid=X,comm=Y\fR varies with personality;output may be one column named "X,comm=Y" or two columnsnamed "X" and "Y". Use multiple \fB\-o\fR options when in doubt.Use the \fBPS_FORMAT\fR environment variable to specify a defaultas desired; DefSysV and DefBSD are macros that may be used tochoose the default UNIX or BSD columns..opt sdisplay signal format.opt udisplay user\-oriented format.opt vdisplay virtual memory format.opt \-yDo not show flags; show rss in place of addr.This option can only be used with \fB\-l\fR..opt \-\-format \ formatuser\-defined format.  Identical to \fB\-o\fR and \fBo\fR..opt \-\-contextDisplay security context format. (for\ SE\ Linux).\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""".PD.PP.SH "OUTPUT MODIFIERS".\"  .TP.\"  .B C.\"  use raw CPU time for %CPU instead of decaying average.opt \-Hshow process hierarchy (forest).opt N \ namelistSpecify namelist file.  Identical to \fB\-n\fR, see \fB\-n\fR above..opt O \ orderSorting order. (overloaded).brThe BSD \fBO\fR option can act like \fB\-O\fR (user\-defined outputformat with some common fields predefined) or can be used to specifysort order.  Heuristics are used to determine the behavior of thisoption. To ensure that the desired behavior is obtained (sorting orformatting), specify the option in some other way (e.g. with \fB\-O\fRor \fB\-\-sort\fR).For sorting, obsolete BSD \fBO\fR option syntax is\fBO\fR[\fB+\fR|\fB\-\fR]\fIk1\fR[,[\fB+\fR|\fB\-\fR]\fIk2\fR[,...]].It orders the processes listing according to the multilevel sort specified bythe sequence of one\-letter short keys \fIk1\fR, \fIk2\fR, ... describedin the \fBOBSOLETE SORT KEYS\fR section below.The\ "+" is currently optional,merely re\-iterating the default direction on a key,but may help to distinguish an \fBO\fR sort from an \fBO\fR format.The\ "\-" reverses direction only on the key it precedes..opt SSum up some information, such as CPU usage, from dead child processesinto their parent. This is useful for examining a system where aparent process repeatedly forks off short\-lived children to do work..opt cShow the true command name. This is derived from the name of the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -