Chinaunix首页 | 论坛 | 博客
  • 博客访问: 283595
  • 博文数量: 82
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 874
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-21 09:58
个人简介

traveling in cumputer science!!

文章分类

全部博文(82)

文章存档

2016年(13)

2015年(69)

我的朋友

分类: LINUX

2015-11-24 14:07:12

1.top----The easiest way to find out what processes are running on your server is to run the top, with Enter to refresh

点击(此处)折叠或打开

  1. top - 21:55:22 up 1:44, 6 users, load average: 1.59, 2.01, 1.99
  2. Tasks: 253 total, 3 running, 250 sleeping, 0 stopped, 0 zombie
  3. %Cpu(s): 1.5 us, 0.5 sy, 0.0 ni, 98.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
  4. KiB Mem: 7849568 total, 3608720 used, 4240848 free, 248612 buffers
  5. KiB Swap: 8000508 total, 0 used, 8000508 free. 1693112 cached Mem

  6.   PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  7.  2647 warrior 20 0 1400096 356084 97856 R 4.3 4.5 25:56.53 firefox
  8.  2004 warrior 20 0 1355964 108060 61016 S 3.6 1.4 3:38.90 compiz
  9.  1223 root 20 0 632244 135200 117156 S 3.3 1.7 9:46.83 Xorg
  10.  2191 warrior 20 0 594920 40764 26316 S 2.7 0.5 0:34.97 gnome-terminal
  11.  3660 warrior 20 0 1158096 171660 67856 S 1.7 2.2 0:47.05 chromium-browse
  12.  2724 warrior 20 0 534252 68568 44652 S 1.3 0.9 1:33.53 plugin-containe
  13.  3229 warrior 20 0 2074632 310320 151736 S 0.7 4.0 2:16.63 chromium-browse
  14.  3675 warrior 20 0 991292 74248 40532 S 0.3 0.9 0:09.51 chromium-browse
  15.  4314 warrior 20 0 29272 3344 2716 R 0.3 0.0 0:00.04 top
  16.     1 root 20 0 33888 4400 2712 S 0.0 0.1 0:01.03 init
  17.     2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
  18.     3 root 20 0 0 0 0 S 0.0 0.0 0:00.04 ksoftirqd/0
  19.     4 root 20 0 0 0 0 S 0.0 0.0 0:00.51 kworker
2.htop An improved version of top, called htop, is available in the repositories. Install it with this command:

点击(此处)折叠或打开

  1. sudo apt-get install htop
If we run the htop command, we will see that there is a more user-friendly display:

点击(此处)折叠或打开

  1. Mem[||||||||||| 49/995MB] Load average: 0.00 0.03 0.05
  2.   CPU[ 0.0%] Tasks: 21, 3 thr; 1 running
  3.   Swp[ 0/0MB] Uptime: 00:58:11

  4.   PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
  5.  1259 root 20 0 25660 1880 1368 R 0.0 0.2 0:00.06 htop
  6.     1 root 20 0 24188 2120 1300 S 0.0 0.2 0:00.56 /sbin/init
  7.   311 root 20 0 17224 636 440 S 0.0 0.1 0:00.07 upstart-udev-brid
  8.   314 root 20 0 21592 1280 760 S 0.0 0.1 0:00.06 /sbin/udevd --dae
  9.   389 messagebu 20 0 23808 688 444 S 0.0 0.1 0:00.01 dbus-daemon --sys
  10.   407 syslog 20 0 243M 1404 1080 S 0.0 0.1 0:00.02 rsyslogd -c5
  11.   408 syslog 20 0 243M 1404 1080 S 0.0 0.1 0:00.00 rsyslogd -c5
  12.   409 syslog 20 0 243M 1404 1080 S 0.0 0.1 0:00.00 rsyslogd -c5
  13.   406 syslog 20 0 243M 1404 1080 S 0.0 0.1 0:00.04 rsyslogd -c5
  14.   553 root 20 0 15180 400 204 S 0.0 0.0 0:00.01 upstart-socket-br
3.ps 
When called without arguments, the output can be a bit lack-luster:

点击(此处)折叠或打开

  1. PID TTY TIME CMD
  2.  2613 pts/23 00:00:00 bash
  3.  4323 pts/23 00:00:00 ps
To get a more complete picture of the processes on this system, we can run the following:
ps aux

点击(此处)折叠或打开

  1. warrior@warrior:~/Coding/PythonCode/crawler$ ps aux | more -10
  2. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
  3. root 1 0.0 0.0 33888 4400 ? Ss 20:11 0:01 /sbin/init
  4. root 2 0.0 0.0 0 0 ? S 20:11 0:00 [kthreadd]
  5. root 3 0.0 0.0 0 0 ? S 20:11 0:00 [ksoftirqd/0]
  6. root 4 0.0 0.0 0 0 ? S 20:11 0:00 [kworker/0:0]
  7. root 5 0.0 0.0 0 0 ? S< 20:11 0:00 [kworker/0:0H]
  8. root 7 0.1 0.0 0 0 ? R 20:11 0:07 [rcu_sched]
  9. root 8 0.0 0.0 0 0 ? S 20:11 0:00 [rcuos/0]
  10. root 9 0.0 0.0 0 0 ? S 20:11 0:00 [rcuos/1]
  11. root 10 0.0 0.0 0 0 ? S 20:11 0:00 [rcuos/2]
To see a tree view, where hierarchal relationships are illustrated, we can run the command with these options:
ps axjf

点击(此处)折叠或打开

  1. PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
  2.     0 2 0 0 ? -1 S 0 0:00 [kthreadd]
  3.     2 3 0 0 ? -1 S 0 0:00 \_ [ksoftirqd/0]
  4.     2 6 0 0 ? -1 S 0 0:00 \_ [migration/0]
  5.     2 7 0 0 ? -1 S 0 0:00 \_ [watchdog/0]
  6.     2 8 0 0 ? -1 S< 0 0:00 \_ [cpuset]
  7.     2 9 0 0 ? -1 S< 0 0:00 \_ [khelper]
  8.     2 10 0 0 ? -1 S 0 0:00 \_ [kdevtmpfs]
  9.     2 11 0 0 ? -1 S< 0 0:00 \_ [netns]
  10. ......
4.pgrep
A quick way of getting the PID of a process is with the pgrep command:

点击(此处)折叠或打开

  1. warrior@warrior:~/Coding/PythonCode/crawler$ pgrep bash
  2. 2199
  3. 2509
  4. 2613
  5. 3485
5. kill
The most common way of passing signals to a program is with the kill command.

点击(此处)折叠或打开

  1. kill PID_of_target_process






阅读(1384) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~