Ps
(compatible commands) |
|||
Line 12: | Line 12: | ||
| ps -el || ps axl | | ps -el || ps axl | ||
|- | |- | ||
− | | ps -u x || <nowiki>ps axo ruser,pid,tty,time,comm | awk '/^x |TT/{printf("%5s %-8s | + | | ps -u x || <nowiki>ps axo ruser,pid,tty,time,comm | awk '/^x |TT/{printf("%5s %-8s �s %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> | | ps -e -C bash || <nowiki>ps axo pid,tty,time,comm | egrep 'PID.*TT| b[a]sh$'</nowiki> |
Revision as of 19:55, 11 April 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 �s %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.
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