Ps
m (Reverted edits by 83.211.3.16 (Talk); changed back to last version by Jimbo) |
|||
(5 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
[[ps]] will show your running processes. If run from a regular user shell or an xterm window, it'll only show you '''your''' processes. If run as root, it will show ''all'' processes. | [[ps]] will show your running processes. If run from a regular user shell or an xterm window, it'll only show you '''your''' processes. If run as root, it will show ''all'' processes. | ||
− | + | [[BSD]] does not support the switches (options) defined by the [[UNIX]] standard because historical BSD implementations assigned conflicting meanings to these switches. Enhancements commonly found on [[Linux]] and [[Solaris]] are likewise unavailable. Near-equivalent common options are as follows: | |
+ | |||
+ | {| border="1" cellpadding="5" cellspacing="0" | ||
+ | ! UNIX !! BSD | ||
+ | |- | ||
+ | | ps || <nowiki>ps opid,tty,time,comm | egrep ' '`ps otty= $$`' |TT'</nowiki> | ||
+ | |- | ||
+ | | ps -ef || ps aux | ||
+ | |- | ||
+ | | ps -el || ps axl | ||
+ | |- | ||
+ | | ps -u x || <nowiki>ps axo ruser,pid,tty,time,comm | awk '/^x |TT/{printf("%5s %-8s %11s %s\n", $2,$3,$4,$5)}'</nowiki> | ||
+ | |- | ||
+ | | ps -e -C bash || <nowiki>ps axo pid,tty,time,comm | egrep 'PID.*TT| b[a]sh$'</nowiki> | ||
+ | |} | ||
+ | |||
+ | While the [[BSD]] ps does ignore the "-" in front of options, it is better to avoid using it. Besides being less to type, this makes your habits and scripts compatible with several other systems. [[Linux]], [[AIX]], and [[Tru64]] all follow the UNIX standard when the "-" is used. They act like BSD when the "-" is not used. | ||
+ | |||
+ | For a BSD-style ps on a [[Solaris]] system, use /usr/ucb/ps instead of the normal UNIX-standard ps. | ||
+ | |||
+ | ==Common flags== | ||
+ | |||
+ | ;a: all users, not just the user running the [[ps]] command | ||
+ | ;u: show system info on commands (user, pid, cpu% etc) | ||
+ | ;c: show the command only, not the path to it | ||
+ | ;x: show processes that don't have a terminal controlling them | ||
+ | ;r: sort by CPU use | ||
+ | ;w: wide output | ||
+ | |||
+ | [[Category:System Commands]] |
Latest revision as of 13:09, 5 May 2007
ps will show your running processes. If run from a regular user shell or an xterm window, it'll only show you your processes. If run as root, it will show all processes.
BSD does not support the switches (options) defined by the UNIX standard because historical BSD implementations assigned conflicting meanings to these switches. Enhancements commonly found on Linux and Solaris are likewise unavailable. Near-equivalent common options are as follows:
UNIX | BSD |
---|---|
ps | ps opid,tty,time,comm | egrep ' '`ps otty= $$`' |TT' |
ps -ef | ps aux |
ps -el | ps axl |
ps -u x | ps axo ruser,pid,tty,time,comm | awk '/^x |TT/{printf("%5s %-8s %11s %s\n", $2,$3,$4,$5)}' |
ps -e -C bash | ps axo pid,tty,time,comm | egrep 'PID.*TT| b[a]sh$' |
While the BSD ps does ignore the "-" in front of options, it is better to avoid using it. Besides being less to type, this makes your habits and scripts compatible with several other systems. Linux, AIX, and Tru64 all follow the UNIX standard when the "-" is used. They act like BSD when the "-" is not used.
For a BSD-style ps on a Solaris system, use /usr/ucb/ps instead of the normal UNIX-standard ps.
[edit] Common flags
- a
- all users, not just the user running the ps command
- u
- show system info on commands (user, pid, cpu% etc)
- c
- show the command only, not the path to it
- x
- show processes that don't have a terminal controlling them
- r
- sort by CPU use
- w
- wide output