ps

Process status, information about processes running in memory.

Syntax

      ps [-aCcefhjlMmrSTuvwx] [-O fmt] [-o fmt]  [-G gid[,gid...]] [-g grp[,grp...]] [-u uid[,uid...]]
            [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]

      ps [-L]

Options
     -a    Display information about other users' processes as well as your own.

     -A    Display information about other users' processes, including those without controlling terminals.

     -c    Change the 'command' column output to just contain the executable name
           rather than the full command line.

     -C    Change the way the cpu percentage is calculated by using a 'raw' cpu calculation
           that ignores 'resident' time (this normally has no effect).       

     -d    Like -A, but excludes session leaders.

     -e    Display information about other users' processes, including those without controlling terminals.
           Identical to -A.

     -E    Display the environment as well.  This does not reflect changes in the environment after process launch.

     -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 than 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 available keywords available for the -O and -o options.

     -l    Display information associated with the following keywords: uid,
           pid, ppid, cpu, pri, nice, vsz, rss, wchan, state, tt, time and command.

     -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 can  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.
           Keywords can  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.

     -p    Display information associated with the specified process IDs.

     -r    Sort by current cpu usage, instead of the combination of controlling terminal and process ID.

     -S    Change the way the process time is calculated by summing all
           exited children to their parent process.

     -T    Display information about processes attached to the device associated with the standard input.

     -t    Display information about processes attached to the specified terminal device.

     -U    Display the processes belonging to the specified real user IDs.

     -u    Display the processes belonging to the specified usernames.

     -v    Display information associated with the following keywords: pid, state, time, sl,
           re, pagein, vsz, rss, lim, tsiz, %cpu, %mem and command.
           The -v option implies the -m option.

     -w    Use 132 columns to display information, instead of the default which is your window size.
           If the -w option is specified more than once, ps will use as many columns as necessary
           without regard for your window size. When output is not to a terminal, an unlimited number of
columns are always used. -X When displaying processes matched by other options, skip any processes which do not have a controlling terminal. -x When displaying processes matched by other options, include processes which do not have a controlling terminal. This is the opposite of the -X option. If both -X and -x are specified in the same command, then ps will use the one which was specified last.

Since ps cannot run faster than the system and is run as any other scheduled process, the information it displays can never be exact.

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.

Environment

The following environment variables affect the execution of ps:

COLUMNS If set, specifies the user's preferred output width in column positions. By default, ps attempts to automatically
determine the terminal width.

Examples

Display all processes associated with any controlling terminal:

$ ps

Display all processes on the current controlling terminal. (Linux/POSIX behavior):

$ ps -T

“A human being is a part of the whole, called by us "Universe”, a part limited in time and space" ~ Albert Einstein

Related macOS commands

execsnoop - Snoop new process execution.
kill - Stop a process from running.
lsof - List open files.
opensnoop - Snoop file opens as they occur.
top - Display process information.
w - Show who is logged on and what they are doing.


 
Copyright © 1999-2024 SS64.com
Some rights reserved