码迷,mamicode.com
首页 > 系统相关 > 详细

Show All Running Processes in Linux

时间:2014-10-16 00:27:51      阅读:402      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   io   os   ar   for   

ps由于历史的原因,所以很奇特,有些命令必须加"-",比如:

ps A

上面的写法是错误的

********* simple selection *********  ********* selection by list *********
-A all processes                      -C by command name
-N negate selection                   -G by real group ID (supports names)
-a all w/ tty except session leaders  -U by real user ID (supports names)
-d all except session leaders         -g by session OR by effective group name
-e all processes                      -p by process ID
T  all processes on this terminal     -s processes in the sessions given
a  all w/ tty, including other users  -t by tty
g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)
r  only running processes             U  processes for specified users
x  processes w/o controlling ttys     t  by tty
*********** output format **********  *********** long options ***********
-o,o user-defined  -f full            --Group --User --pid --cols --ppid
-j,j job control   s  signal          --group --user --sid --rows --info
-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect
-l,l long          u  user-oriented   --sort --tty --forest --version
-F   extra full    X  registers       --heading --no-heading --context
                    ********* misc options *********
-V,V  show version      L  list format codes  f  ASCII art forest
-m,m,-L,-T,H  threads   S  children in sum    -y change -l format
-M,Z  security data     c  true command name  -c scheduling class
-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy
[maijunjin@localhost smplayer]$ ps A
ERROR: Unsupported option (BSD syntax)
********* simple selection *********  ********* selection by list *********
-A all processes                      -C by command name
-N negate selection                   -G by real group ID (supports names)
-a all w/ tty except session leaders  -U by real user ID (supports names)
-d all except session leaders         -g by session OR by effective group name
-e all processes                      -p by process ID
T  all processes on this terminal     -s processes in the sessions given
a  all w/ tty, including other users  -t by tty
g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)
r  only running processes             U  processes for specified users
x  processes w/o controlling ttys     t  by tty
*********** output format **********  *********** long options ***********
-o,o user-defined  -f full            --Group --User --pid --cols --ppid
-j,j job control   s  signal          --group --user --sid --rows --info
-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect
-l,l long          u  user-oriented   --sort --tty --forest --version
-F   extra full    X  registers       --heading --no-heading --context
                    ********* misc options *********
-V,V  show version      L  list format codes  f  ASCII art forest
-m,m,-L,-T,H  threads   S  children in sum    -y change -l format
-M,Z  security data     c  true command name  -c scheduling class
-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy

 

 

How do I see all running process in Linux operating systems using command line or GUI options?

You need to use the ps command. It provide information about the currently running processes, including their process identification numbers (PIDs). Both Linux and UNIX support the ps command to display information about all running process. The ps command gives a snapshot of the current processes. If you want a repetitive update of this status, use top, atop, and/or htop command as described below.

Tutorial details 
Difficulty Easy (rss)
Root privileges Yes
Requirements ps/top/htop
Estimated completion time 5 minutes

Apart from ps command, you can also use the following commands to display info about processes on Linux:

  1. top command : Display and update sorted information about processes.
  2. atop : Advanced System & Process Monitor.
  3. htop : Interactive process viewer.

The ps command

Type the following ps command to display all running process:

# ps aux | less

Where,

  • -A: select all processes
  • a: select all processes on a terminal, including those of other users
  • x: select processes without controlling ttys

Task: see every process on the system

# ps -A
# ps -e

上面两条命令是一样的

Task: See every process except those running as root

# ps -U root -u root -N
[maijunjin@localhost Documents]$ ps -U maijunjin|grep su
 3640 pts/2    00:00:00 su
23654 pts/2    00:00:00 su
[maijunjin@localhost Documents]$ ps -u maijunjin|grep su

 

Task: See process run by user vivek

# ps -u vivek

Task: top command

The top program provides a dynamic real-time view of a running system. Type the top at command prompt:

# top

Output:

bubuko.com,布布扣

Fig.01: top command: Display Linux Tasks

To quit press q, for help press h.

Task: display a tree of processes

pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.

$ pstree


Sample outputs:

bubuko.com,布布扣

Fig.02: pstree - Display a tree of processes

Task: Print a process tree using ps

# ps -ejH
# ps axjf

Task: Get info about threads

Type the following command:

# ps -ejH
# ps axjf

Task: Get info about threads

Type the following command:

 

Show All Running Processes in Linux

标签:des   style   blog   http   color   io   os   ar   for   

原文地址:http://www.cnblogs.com/ghgyj/p/4027407.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!