进程管理
静态查看进程ps
查看进程
[root@localhost ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.2 0.1 128156 1720 ? Ss 06:34 0:01 /usr/lib/syste
root 2 0.0 0.0 0 0 ? S 06:34 0:00 [kthreadd]
查看头两行进程
[root@localhost ~]# ps aux |head -2
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 0.1 128156 1196 ? Ss 06:34 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
r 运行 t 停止 s休眠 z 卡死
查看进程的父子关系
[root@localhost ~]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 06:34 ? 00:00:01 /usr/lib/systemd/systemd --swi
root 2 0 0 06:34 ? 00:00:00 [kthreadd]
排队自定义显示列
[root@localhost ~]# ps axo uid,ppid,user
UID PPID USER
0 0 root
0 0 root
0 2 root
top 动态查看进程
每秒查看进程
[root@localhost ~]# top
top - 06:52:39 up 18 min, 2 users, load average: 0.11, 0.34, 0.28
Tasks: 203 total, 3 running, 200 sleeping, 0 stopped, 0 zombie
%Cpu(s): 5.4 us, 3.9 sy, 0.7 ni, 88.9 id, 0.0 wa, 0.0 hi, 1.1 si, 0.0 st
KiB Mem : 997956 total, 69688 free, 720048 used, 208220 buff/cache
KiB Swap: 2097148 total, 1785596 free, 311552 used. 70508 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4439 root 30 10 319544 12136 4820 R 4.7 1.2 0:00.78 urlgrabber+
2153 root 20 0 2970032 115008 10092 S 3.7 11.5 0:16.00 gnome-shell
1315 root 20 0 321516 22204 3768 S 3.3 2.2 0:07.19 X
每三秒刷新
[root@localhost ~]# top -d 3
top - 06:53:21 up 19 min, 2 users, load average: 0.33, 0.37, 0.29
Tasks: 204 total, 2 running, 202 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.8 us, 5.3 sy, 3.5 ni, 87.7 id, 0.0 wa, 0.0 hi, 0.7 si, 0.0 st
KiB Mem : 997956 total, 73692 free, 732556 used, 191708 buff/cache
KiB Swap: 2097148 total, 1783804 free, 313344 used. 66284 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2153 root 20 0 2970032 115620 10664 S 3.0 11.6 0:16.57 gnome-shell
1315 root 20 0 321516 22204 3768 R 1.7 2.2 0:07.48 X
4526 root 30 10 319148 11872 4816 S 1.7 1.2 0:00.05 urlgrabber+
2718 root 20 0 755508 15504 5552 S 1.3 1.6 0:02.65 gnome-term+
查看pid为1的进程并3秒刷新一次
[root@localhost ~]# top -d 3 -p 1
top - 06:54:37 up 20 min, 2 users, load average: 0.28, 0.35, 0.29
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 91.7 us, 5.6 sy, 0.0 ni, 2.3 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 997956 total, 70460 free, 548388 used, 379108 buff/cache
KiB Swap: 2097148 total, 1771004 free, 326144 used. 242124 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 128156 2436 700 S 0.0 0.2 0:01.47 systemd
第五行:交换分区(虚拟内存)
查看终端
[root@localhost ~]# tty
/dev/pts/0
信号控制进程
查询kill命令
[root@localhost ~]# kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
强制杀死
[root@localhost ~]# kill -9 5021
创建一个睡眠示例程序
nice -n -5 sleep 6000&
修改他的优先值
renice -20 3811
pid的进程文件夹
/proc/pid
求帮助
[root@localhost ~]# vim --help
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 10 2018 23:54:40)
usage: vim [arguments] [file ..] edit specified file(s)
or: vim [arguments] - read text from stdin
or: vim [arguments] -t tag edit file where tag is defined
or: vim [arguments] -q [errorfile] edit file with first error
Arguments:
-- Only file names after this
-v Vi mode (like "vi")
-e Ex mode (like "ex")
文章评论