1.一个简单粗暴的指令,显示进程信息,并显示内存,内核,等的占用情况--top:
top - 00:03:48 up 1:09, 2 users, load average: 1.15, 1.22, 1.23
Tasks: 256 total, 1 running, 255 sleeping, 0 stopped, 0 zombie
%Cpu(s): 3.5 us, 1.一个简单粗暴的指令,显示进程信息,并显示内存,内核,等的占用情况--top: 0.9 sy, 0.0 ni, 95.5 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 7849568 total, 3278076 used, 4571492 free, 255256 buffers
KiB Swap: 8000508 total,53556 used, 7946952 free. 1212288 cached Mem
PID USER PR NIVIRTRESSHR S %CPU %MEM TIME+ COMMAND
4610 warrior 20 0 1025836 33300 22848 S 6.3 0.4 0:12.27 gnome-scre+
4975 warrior 20 0 29200 3304 2784 R 6.3 0.0 0:00.01 top
1 root 20 0 33908 4324 2620 S 0.0 0.1 0:01.05 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.03 ksoftirqd/0
4 root 20 0 0 0 0 S 0.0 0.0 0:00.29 kworker/0:0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:+
2.htop是top的升级版,通过如下指令安装:
sudo apt-get install htop
显示效果:
Mem[||||||||||| 49/995MB] Load average: 0.00 0.03 0.05
CPU[ 0.0%] Tasks: 21, 3 thr; 1 running
Swp[ 0/0MB] Uptime: 00:58:11
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1259 root 20 0 25660 1880 1368 R 0.0 0.2 0:00.06 htop
1 root 20 0 24188 2120 1300 S 0.0 0.2 0:00.56 /sbin/init
311 root 20 0 17224 636 440 S 0.0 0.1 0:00.07 upstart-udev-brid
314 root 20 0 21592 1280 760 S 0.0 0.1 0:00.06 /sbin/udevd --dae
389 messagebu 20 0 23808 688 444 S 0.0 0.1 0:00.01 dbus-daemon --sys
407 syslog 20 0 243M 1404 1080 S 0.0 0.1 0:00.02 rsyslogd -c5
408 syslog 20 0 243M 1404 1080 S 0.0 0.1 0:00.00 rsyslogd -c5
409 syslog 20 0 243M 1404 1080 S 0.0 0.1 0:00.00 rsyslogd -c5
406 syslog 20 0 243M 1404 1080 S 0.0 0.1 0:00.04 rsyslogd -c5
553 root 20 0 15180 400 204 S 0.0 0.0 0:00.01 upstart-socket-br
3.ps 是一个只查看进程状态的指令,可根据需要加入一下显示参数:
warrior@warrior:~/Coding/PythonCode/crawler$ ps aux | more -10
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 33888 4400 ? Ss 20:11 0:01 /sbin/init
root 2 0.0 0.0 0 0 ? S 20:11 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 20:11 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S 20:11 0:00 [kworker/0:0]
root 5 0.0 0.0 0 0 ? S< 20:11
4. pgrep 根据进程名字,获得对应PID,指令格式:pgrep processname
warrior@warrior:~$ pgrep sshd
1194
warrior@warrior:~$ pgrep bash
4911
5.kill 关闭指定进程:
kill PID_of_target_process
Linux ps进程状态码:http://www.linuxdiyf.com/linux/14113.html
Linux进程状态解析之R、S、D:http://www.linuxdiyf.com/linux/285.html
Linux进程状态解析之T、Z、X:http://www.linuxdiyf.com/linux/230.html