在shell中执行man ps可查看mac命令行中ps的具体使用用法。
man ps
输出结果为:
PS(1) General Commands Manual PS(1)
NAME
ps – process status
SYNOPSIS
ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]] [-g grp[,grp...]] [-u uid[,uid...]] [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
ps [-L]
DESCRIPTION
The ps utility displays a header line, followed by lines containing information about all of your processes that have controlling terminals.
A different set of processes can be selected for display by using any combination of the -a, -G, -g, -p, -T, -t, -U, and -u options. If more than one of these options are given, then
ps will select all processes which are matched by at least one of the given options.
For the processes which have been selected for display, ps will usually display one line per process. The -M option may result in multiple output lines (one line per thread) for some
processes. By default all of these output lines are sorted first by controlling terminal, then by process ID. The -m, -r, and -v options will change the sort order. If more than one
sorting option was given, then the selected processes will be sorted by the last sorting option which was specified.
For the processes which have been selected for display, the information to display is selected based on a set of keywords (see the -L, -O, and -o options). The default output format
includes, for each process, the process' ID, controlling terminal, CPU time (including both user and system time), state, and associated command.
The options are as follows:
-A Display information about other users' processes, including those without controlling terminals.
-a Display information about other users' processes as well as your own. This will skip any processes which do not have a controlling terminal, unless the -x option is also
specified.
-C Change the way the CPU percentage is calculated by using a “raw” CPU calculation that ignores “resident” time (this normally has no effect).
-c Change the “command” column output to just contain the executable name, rather than the full command line.
-d Like -A, but excludes session leaders.
-E Display the environment as well. This does not reflect changes in the environment after process launch.
-e Identical to -A.
-f Display the uid, pid, parent pid, recent CPU usage, process start time, controlling tty, elapsed CPU usage, and the associated command. If the -u option is also used, display
the user name rather then the numeric uid. When -o or -O is used to add to the display following -f, the command field is not truncated as severely as it is in other formats.
-G Display information about processes which are running with the specified real group IDs.
-g Display information about processes with the specified process group leaders.
-h Repeat the information header as often as necessary to guarantee one header per page of information.
-j Print information associated with the following keywords: user, pid, ppid, pgid, sess, jobc, state, tt, time, and command.
-L List the set of keywords available for the -O and -o options.
-l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD.
-M Print the threads corresponding to each task.
-m Sort by memory usage, instead of the combination of controlling terminal and process ID.
-O Add the information associated with the space or comma separated list of keywords specified, after the process ID, in the default information display. Keywords may be appended
with an equals (‘=’) sign and a string. This causes the printed header to use the specified string instead of the standard header.
-o Display information associated with the space or comma separated list of keywords specified. Multiple keywords may also be given in the form of more than one -o option.
Keywords may be appended with an equals (‘=’) sign and a string. This causes the printed header to use the specified string instead of the standard header. If all keywords
have empty header texts, no header line is written.
...
-e : 等价于-A,展示所有的用户进程;
-f : 可以理解为格式化(format)方式展示进程相关信息;