ps(1) — Commands
OSF
NAME
ps − Displays current process status
SYNOPSIS
ps [-adejflm] [-oO specifier][=header],... [-t tlist] [-p plist] [-s slist] [-u ulist]
[-g glist] [-s slist]
BSD Compatible Syntax:
ps [aAeghkjlLmsSTuvwx] [oO specifier][=header],... [t tty] [process_number]
The ps command displays the current process status.
FLAGS
The following flags can be used with ps:
-aPrints information to standard output about all processes except the process group leaders and processes not associated with a terminal.
-dPrints information to standard output about all processes except the process group leaders.
-ePrints information to standard output about all processes except kernel processes.
-fGenerates a full listing.
-g glistPrints only information about processes that are in the process groups listed in glist. The glist is either a list of process-group identifiers or a list of process-group identifiers enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces, or both.
-jProduces job control information, with fields specified for user, pid, ppid, pgid, sess, jobc, state, tname, cputime and comm/.
-lGenerates a long listing.
-mPrints all threads in a task, if the task has more than one.
-o specifier[=header],...
Specifies a list of format specifiers to describe the output format.
-O specifier[=header],...
Same as o, except it displays the fields specified by pid, state, tname, cputime, and comm in addition to the specifiers supplied on the command line.
-p plistDisplays only information about processes with the process numbers specified in plist. plist is either a list of process ID numbers or a list of process ID numbers enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces, or both.
-s slistDisplays information about processes belonging to the sessions specified in slist.
-t tlistDisplays only information about processes associated with the terminals listed in tlist. tlist is either a list of terminal identifiers or a list of terminal identifiers enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces, or both.
-u ulistDisplays only information about processes with the user ID numbers or login names specified in ulist. ulist is either a list of user IDs or a list of user IDs enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces, or both. In the listing, ps displays the numerical user ID unless the -f flag is used; then it displays the login name.
The following BSD compatible flags can be used with ps:
aAsks for information regarding processes associated with terminals (ordinarily only one’s own processes are displayed).
AIncreases the argument space.
eAsks for the environment to be printed, as well as the arguments to the command.
gAsks for all processes. Without this flag, ps only prints interesting processes. Processes are deemed to be uninteresting if they are process group leaders. This normally eliminates top-level command interpreters and processes waiting for users to log in on free terminals.
hRepeats the header after each screenful of information.
jProduces job control information, with fields specified by user, ppid, pgid, sess, and jobc.
lAsks for a detailed list, with fields specified by ppid, cp, pri, nice, vsize, rssize and wchan.
LLists all available format specifiers.
mPrints all threads in a task, if the task has more than one.
o specifier[=header],...
Specifies a list of format specifiers to describe the output format.
O specifier[=header],...
Same as o, except it displays the fields specified by pid, state, tname, cputime, and comm in addition to the specifiers supplied on the command line.
sGives signal states of the processes, with fields specified by uid, cursig, sig, sigmask, sigignore, and sigcatch.
SPrints usage summaries (total usage of a command, as opposed to current usage).
tttyLists only processes for the specified tty.
TLists all processes on your tty.
uProduces a user oriented output. This includes fields specified by user, pcpu, pmem, vsize, rssize, and start.
vProduces a version of the output containing virtual memory statistics. This includes fields specified by cputime, sl, pagein, vsize, rssize, pcpu, and pmem.
wUses a wide output format (132 columns (bytes) rather than 80); if this flag is doubled (ww), uses an arbitrarily wide output. This information determines how much of long commands to print.
xAsks even about processes with no terminal.
process_number
Restricts output to the specified process. This argument must be entered last on the command line.
DESCRIPTION
While ps is a fairly accurate snapshot of the system, ps cannot begin and finish a snapshot as fast as some processes change state. At times there may be minor discrepancies.
Output formats for each process include the process ID (pid), control terminal of the process (tname), CPU time used by the process (cputime) (this includes both user and system time), the state of the process (state), and an indication of the command that is running (comm).
The state is given by a sequence of letters, for example, RWN. The first letter indicates the status of the process:
RRunnable process
UUninterruptible sleeping process
SProcess sleeping for less than about 20 seconds
IIdle (sleeping longer than about 20 seconds) process
TStopped process
HHalted process
Additional characters after these, if any, indicate additional state information:
WProcess is swapped out (shows a blank space if the process is loaded (in-core)).
>Process has specified a soft limit on memory requirements and is exceeding that limit; such a process is (necessarily) not swapped.
An additional letter may indicate whether a process is running with altered CPU scheduling priority (nice):
NProcess priority is reduced
<Process priority has been artificially raised
+Process is a process group leader with a controlling tty.
Format Specifiers
The following list contains all format specifiers that can be used with ps:
| Specifier | Header | Meaning |
| comm | COMMAND | Command arguments (and environment with BSD e flag) |
| ucomm | COMMAND | Command name for accounting |
| logname | LOGNAME | User’s login name |
| flag | F | Process flags |
| status | STATUS | Process status |
| uid | UID | Process user ID (effective UID) |
| ruid | RUID | Process user ID (real UID) |
| svuid | SVUID | Saved process group ID |
| rgid | RGID | Process group (real GID) |
| svgid | SVGID | Saved process group ID |
| pid | PID | Process ID |
| ppid | PPID | Parent process ID |
| cp | CP | Short-term CPU utilization factor (used in scheduling) |
| wchan | WCHAN | Address of event on which a process is waiting (an address in the system). A symbol is chosen that classifies the address, if available, from the system; otherwise, it is printed numerically. |
| nwchan | WCHAN | In this case, the initial part of the address is trimmed off and is printed hexadecimally, for example, 0x80004000 prints as 4000. |
| cursig | CURSIG | Current signal |
| sig | PENDING | Signals pending to this process |
| sigmask | BLOCKED | Current signal mask |
| sigignore | IGNORED | Signals being ignored |
| sigcatch | CAUGHT | Signals being caught |
| user | USER | Username |
| ruser | RUSER | User ID |
| pgid | PGID | Process group ID |
| jobc | JOBC | Current count of processes qualifying PGID for job control |
| sess | SESS | Session ID |
| tdev | TDEV | Major/minor device for controlling tty |
| tname | TT | Controlling tty device name |
| longtname | TT | Long controlling tty device name |
| tpgid | TPGID | Foreground process group associated with tty |
| tsession | TSESS | Session associated with tty |
| state | STAT | Symbolic process status |
| pri | PRI | Process priority (nonpositive when in noninterruptible wait) |
| usrpri | UPR | Base scheduling priority |
| nice | NI | Process scheduling increment (see the setpriority() call). |
| vsize | VSZ | Process virtual address size |
| rssize | RSS | Real memory (resident set) size of the process (in 1024 byte units) |
| u_procp | UPROCP | Address of process in user area |
| umask | UMASK | Process umask |
| acflag | ACFLG | Process accounting flag |
| start | STARTED | Start time of process. If start time was more than 24 hours ago, gives the date. |
| lstart | STARTED | Start time and date of process |
| cputime | TIME | Current CPU time used |
| usertime | USER | Time spent in user space |
| systime | SYSTEM | Time spent in system |
| pcpu | %CPU | Percent CPU usage. This is a decaying average of up to a minute of previous (real) time. Since the time base over which this is computed varies (since processes may be very young), it is possible for the sum of all %CPU fields to exceed 100%. |
| pmem | %MEM | Percent real memory usage |
| sl | SL | Sleep time |
| pagein | PAGEIN | Number of disk I/Os resulting from references by the process to pages not loaded in core. |
| minflt | MINFLT | Page reclaims |
| majflt | MAJFLT | Page faults |
| nswap | NSWAP | Swaps |
| inblock | INBLK | Block input operations |
| oublock | OUBLK | Block output operations |
| msgsnd | MSGSND | Messages sent |
| msgrcv | MSGRCV | Messages received |
| nsignals | NSIGS | Signals received |
| nvcsw | VCSW | Voluntary context switches |
| nivcsw | IVCSW | Involuntary context switches |
| scount | SCNT | Suspend count |
Compound format specifiers are made up of groups of individual format specifiers, as follows:
| Specifier | Meaning |
| RUSAGE | minflt, majflt, nswap, inblock, oublock, msgsnd, msgrcv, nsigs, nvcsw, nivcsw |
| THREAD | user, pcpu, pri, scnt, wchan, usertime, systime |
| DFMT (default printing format) | pid, tname, state, cputime, comm |
| LFMT (BSD l format) | uid, pid, ppid, cp, pri, nice, vsz, rss, wchan, state, tname, cputime, comm |
| JFMT (j format) | user, pid, ppid, pgid, sess, jobc, state, tname, cputime, comm |
| SFMT (BSD s format) | uid, pid, cursig, sig, sigmask, sigignore, sigcatch, stat, tname, comm |
| VFMT (BSD v format) | pid, tt, state, cputime, sl, pagein, vsz, rss, pcpu, pmem, comm |
| UFMT (BSD u format) | uname, pid, pcpu, pmem, vsz, rss, tt, state, start, cputime, comm |
| F5FMT (f format) | uname, pid, ppid, pcpu, start, tt, cputime, comm |
| L5FMT (l format) | flag, state, uid, pid, ppid, pcpu, pri, nice, rss, wchan, tt, cputime, ucomm |
| FL5FMT (lf format) | flag, state, uid, pid, ppid, pcpu, pri, nice, rss, wchan, start, cputime, comm |
| process_flags | Flags associated with process as in <sys/proc.h> |
The flags associated with process as in <sys/proc.h> (see process_flags in the preceding table) are as follows:
| Symbolic Constant | Flag Value (Hex) | Meaning |
| SLOAD | 0x00000001 | In core |
| SSYS | 0x00000002 | Swapper or pager process |
| STRC | 0x00000010 | Process is being traced |
| SWTED | 0x00000020 | Another tracing flag |
| SOMASK | 0x00000200 | Restore old mask after taking signal |
| SWEXIT | 0x00000400 | Working on exiting |
| SPHYSIO | 0x00000800 | Doing physical I/O |
| SPAGV | 0x00008000 | Init data space on demand, from vnode |
| SSEQL | 0x00010000 | User warned of sequential vm behavior |
| SUANOM | 0x00020000 | User warned of random vm behavior |
| STIMO | 0x00040000 | Timing out during sleep |
| SOUSIG | 0x00100000 | Using old signal mechansim |
| SOWEUPC | 0x00200000 | Owe process an addupc() call |
| SCTTY | 0x00800000 | Has a controlling terminal |
| SXONLY | 0x02000000 | Process image read-protected |
| SNOCLDSTOP | 0x40000000 | No SIGCHLD when children stop |
| SEXEC | 0x80000000 | Process called exec |
<defunct>
A process that has exited but whose parent process has not waited for it is marked <defunct>.
<exiting>
A process that is blocked trying to exit is marked <exiting>.
The ps program examines memory to get the filename and arguments given when the process was created. The method is inherently somewhat unreliable because a process can destroy this information, so the names cannot be counted on too much.
EXAMPLES
1.To list all your processes, enter:
ps
2.To list all processes except kernel processes, enter:
ps -e
The BSD equivalent looks like this:
ps ax
3.To list processes owned by specific users, enter:
ps -f -l -ujim,jane,su
4.To list processes associated with a specific tty, enter:
ps -t console
The BSD equivalent looks like this:
ps tco
5.To display only the pid, user, and comm information for all processes, enter:
ps -o pid,user,comm -e
6.To display the parent process ID under the header PARENT, as well as the default headers (fields specified by pid, state, tname, cputime, comm), enter:
ps -O ppid=PARENT
FILES
/devSearched to find tty names
NOTES
The following BSD compatible flags are not supported. (You can reconstruct the output of these flags by using the appropriate format specifiers, however.)
cDisplays the command name, as stored internally in the system for purposes of accounting, rather than the command arguments, which are kept in the process’ address space.
nDisplays numerical output. In a long listing, the wchan field is printed numerically rather than symbolically. In a user listing, the user field is replaced by a uid field.