服务器后端必会(1) - Linux 常用命令

本文最初发表于我的个人站点

1. cd (change directory) 切换目录

使用: cd [目标目录]

常用目录:

  • / (根目录)
  • ~ (用户目录)
  • - (上一次访问的目录)
  • .. (上一级目录)

2. ls (list directory contents) 列出目录内容

使用: ls [OPTION]... [FILE]...

参数:

-a, --all  列出所有文件,包括以点号开头的文件

➜  blog git:(master) ✗ ls -a
.            .git         _config.yml  package.json source
..           .npmignore   db.json      public       themes
.DS_Store    README.md    node_modules scaffolds

-A, --almost-all 列出所有文件,但不包括 . 和 ..

➜  blog git:(master) ✗ ls -A
.DS_Store    .npmignore   _config.yml  node_modules scaffolds    themes
.git         README.md    db.json      package.json source

-h, --human-readable 与 -l 选项配合使用,以人们可读的方式而不是字节数来显示文件大小(如,1K 234M 2G)

➜  / ls -lh
total 43
drwxrwxr-x+ 134 root  admin   4.4K  5 20 23:17 Applications
drwxr-xr-x+  77 root  wheel   2.6K  9  8  2016 Library
drwxr-xr-x@   2 root  wheel    68B 11  4  2015 Network
drwxr-xr-x@   4 root  wheel   136B 11  4  2015 System
drwxr-xr-x    6 root  admin   204B 11  4  2015 Users
drwxrwxrwt@   4 root  admin   136B  5 20 23:18 Volumes
drwxr-xr-x@  39 root  wheel   1.3K 10 18  2015 bin
drwxrwxr-t@   2 root  admin    68B 11  4  2015 cores
drwxr-xr-x    4 root  wheel   136B  3 13 13:33 data
dr-xr-xr-x    3 root  wheel   4.2K  5 15 00:32 dev
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 etc -> private/etc
drwxrwxrwx    9 root  wheel   306B  3 10 14:18 home
-rw-r--r--@   1 root  wheel   313B  8 23  2015 installer.failurerequests
dr-xr-xr-x    2 root  wheel     1B  5 22 13:35 net
drwxrwxr-x@   3 root  wheel   102B  8  3  2015 opt
drwxr-xr-x@   6 root  wheel   204B 11  4  2015 private
drwxr-xr-x@  59 root  wheel   2.0K 11  4  2015 sbin
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 tmp -> private/tmp
drwxr-xr-x@  13 root  wheel   442B  9  8  2016 usr
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 var -> private/var

-i, --inode 显示文件的索引号

➜  blog git:(master) ✗ ls -i
46024308 README.md    45983339 node_modules 45980801 source
46055360 _config.yml  46049463 package.json 45980802 themes
46875612 db.json      45980799 scaffolds

-l 以长格式显示结果 ,也就是详细的列表形式

➜  / ls -l
total 43
drwxrwxr-x+ 134 root  admin  4556  5 20 23:17 Applications
drwxr-xr-x+  77 root  wheel  2618  9  8  2016 Library
drwxr-xr-x@   2 root  wheel    68 11  4  2015 Network
drwxr-xr-x@   4 root  wheel   136 11  4  2015 System
drwxr-xr-x    6 root  admin   204 11  4  2015 Users
drwxrwxrwt@   4 root  admin   136  5 20 23:18 Volumes
drwxr-xr-x@  39 root  wheel  1326 10 18  2015 bin
drwxrwxr-t@   2 root  admin    68 11  4  2015 cores
drwxr-xr-x    4 root  wheel   136  3 13 13:33 data
dr-xr-xr-x    3 root  wheel  4304  5 15 00:32 dev
lrwxr-xr-x@   1 root  wheel    11 11  4  2015 etc -> private/etc
drwxrwxrwx    9 root  wheel   306  3 10 14:18 home
-rw-r--r--@   1 root  wheel   313  8 23  2015 installer.failurerequests
dr-xr-xr-x    2 root  wheel     1  5 22 13:35 net
drwxrwxr-x@   3 root  wheel   102  8  3  2015 opt
drwxr-xr-x@   6 root  wheel   204 11  4  2015 private
drwxr-xr-x@  59 root  wheel  2006 11  4  2015 sbin
lrwxr-xr-x@   1 root  wheel    11 11  4  2015 tmp -> private/tmp
drwxr-xr-x@  13 root  wheel   442  9  8  2016 usr
lrwxr-xr-x@   1 root  wheel    11 11  4  2015 var -> private/var

-S (Size) 以大小排序(大的在最上面,降序)

➜  / ls -S
Applications              home                      Network
dev                       Users                     cores
Library                   private                   etc
sbin                      System                    tmp
bin                       Volumes                   var
usr                       data                      net
installer.failurerequests opt

上面效果不明显,搭配-l和-h来使用更明显,可以看到最大的在上面(如下)

➜  / ls -Shl
total 43
drwxrwxr-x+ 134 root  admin   4.4K  5 20 23:17 Applications
dr-xr-xr-x    3 root  wheel   4.2K  5 15 00:32 dev
drwxr-xr-x+  77 root  wheel   2.6K  9  8  2016 Library
drwxr-xr-x@  59 root  wheel   2.0K 11  4  2015 sbin
drwxr-xr-x@  39 root  wheel   1.3K 10 18  2015 bin
drwxr-xr-x@  13 root  wheel   442B  9  8  2016 usr
-rw-r--r--@   1 root  wheel   313B  8 23  2015 installer.failurerequests
drwxrwxrwx    9 root  wheel   306B  3 10 14:18 home
drwxr-xr-x    6 root  admin   204B 11  4  2015 Users
drwxr-xr-x@   6 root  wheel   204B 11  4  2015 private
drwxr-xr-x@   4 root  wheel   136B 11  4  2015 System
drwxrwxrwt@   4 root  admin   136B  5 20 23:18 Volumes
drwxr-xr-x    4 root  wheel   136B  3 13 13:33 data
drwxrwxr-x@   3 root  wheel   102B  8  3  2015 opt
drwxr-xr-x@   2 root  wheel    68B 11  4  2015 Network
drwxrwxr-t@   2 root  admin    68B 11  4  2015 cores
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 etc -> private/etc
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 tmp -> private/tmp
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 var -> private/var
dr-xr-xr-x    2 root  wheel     1B  5 22 13:35 net

-t 按修改时间排序

搭配-h和-l使用如下,(时间降序,最新的在最前面)

/ ls -thl
total 43
dr-xr-xr-x    2 root  wheel     1B  5 22 13:35 net
drwxrwxrwt@   4 root  admin   136B  5 20 23:18 Volumes
drwxrwxr-x+ 134 root  admin   4.4K  5 20 23:17 Applications
dr-xr-xr-x    3 root  wheel   4.2K  5 15 00:32 dev
drwxr-xr-x    4 root  wheel   136B  3 13 13:33 data
drwxrwxrwx    9 root  wheel   306B  3 10 14:18 home
drwxr-xr-x+  77 root  wheel   2.6K  9  8  2016 Library
drwxr-xr-x@  13 root  wheel   442B  9  8  2016 usr
drwxr-xr-x@   2 root  wheel    68B 11  4  2015 Network
drwxr-xr-x    6 root  admin   204B 11  4  2015 Users
drwxrwxr-t@   2 root  admin    68B 11  4  2015 cores
drwxr-xr-x@   6 root  wheel   204B 11  4  2015 private
drwxr-xr-x@  59 root  wheel   2.0K 11  4  2015 sbin
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 var -> private/var
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 etc -> private/etc
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 tmp -> private/tmp
drwxr-xr-x@   4 root  wheel   136B 11  4  2015 System
drwxr-xr-x@  39 root  wheel   1.3K 10 18  2015 bin
-rw-r--r--@   1 root  wheel   313B  8 23  2015 installer.failurerequests
drwxrwxr-x@   3 root  wheel   102B  8  3  2015 opt

-r, --reverse  反序显示结果

单独使用用处不大,和上面的大小排序,或者时间排序,就可以组成按大小升序,按时间升序的效果

按大小升序

➜  / ls -rShl
total 43
dr-xr-xr-x    2 root  wheel     1B  5 22 13:35 net
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 var -> private/var
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 tmp -> private/tmp
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 etc -> private/etc
drwxrwxr-t@   2 root  admin    68B 11  4  2015 cores
drwxr-xr-x@   2 root  wheel    68B 11  4  2015 Network
drwxrwxr-x@   3 root  wheel   102B  8  3  2015 opt
drwxr-xr-x    4 root  wheel   136B  3 13 13:33 data
drwxrwxrwt@   4 root  admin   136B  5 20 23:18 Volumes
drwxr-xr-x@   4 root  wheel   136B 11  4  2015 System
drwxr-xr-x@   6 root  wheel   204B 11  4  2015 private
drwxr-xr-x    6 root  admin   204B 11  4  2015 Users
drwxrwxrwx    9 root  wheel   306B  3 10 14:18 home
-rw-r--r--@   1 root  wheel   313B  8 23  2015 installer.failurerequests
drwxr-xr-x@  13 root  wheel   442B  9  8  2016 usr
drwxr-xr-x@  39 root  wheel   1.3K 10 18  2015 bin
drwxr-xr-x@  59 root  wheel   2.0K 11  4  2015 sbin
drwxr-xr-x+  77 root  wheel   2.6K  9  8  2016 Library
dr-xr-xr-x    3 root  wheel   4.2K  5 15 00:32 dev
drwxrwxr-x+ 134 root  admin   4.4K  5 20 23:17 Applications

按时间升序

➜  / ls -rthl
total 43
drwxrwxr-x@   3 root  wheel   102B  8  3  2015 opt
-rw-r--r--@   1 root  wheel   313B  8 23  2015 installer.failurerequests
drwxr-xr-x@  39 root  wheel   1.3K 10 18  2015 bin
drwxr-xr-x@   4 root  wheel   136B 11  4  2015 System
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 tmp -> private/tmp
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 etc -> private/etc
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 var -> private/var
drwxr-xr-x@  59 root  wheel   2.0K 11  4  2015 sbin
drwxr-xr-x@   6 root  wheel   204B 11  4  2015 private
drwxrwxr-t@   2 root  admin    68B 11  4  2015 cores
drwxr-xr-x    6 root  admin   204B 11  4  2015 Users
drwxr-xr-x@   2 root  wheel    68B 11  4  2015 Network
drwxr-xr-x@  13 root  wheel   442B  9  8  2016 usr
drwxr-xr-x+  77 root  wheel   2.6K  9  8  2016 Library
drwxrwxrwx    9 root  wheel   306B  3 10 14:18 home
drwxr-xr-x    4 root  wheel   136B  3 13 13:33 data
dr-xr-xr-x    3 root  wheel   4.2K  5 15 00:32 dev
drwxrwxr-x+ 134 root  admin   4.4K  5 20 23:17 Applications
drwxrwxrwt@   4 root  admin   136B  5 20 23:18 Volumes
dr-xr-xr-x    2 root  wheel     1B  5 22 13:35 net

ll = ls -l 相当于简写

➜  / ll
total 43
drwxrwxr-x+ 134 root  admin   4.4K  5 20 23:17 Applications
drwxr-xr-x+  77 root  wheel   2.6K  9  8  2016 Library
drwxr-xr-x@   2 root  wheel    68B 11  4  2015 Network
drwxr-xr-x@   4 root  wheel   136B 11  4  2015 System
drwxr-xr-x    6 root  admin   204B 11  4  2015 Users
drwxrwxrwt@   4 root  admin   136B  5 20 23:18 Volumes
drwxr-xr-x@  39 root  wheel   1.3K 10 18  2015 bin
drwxrwxr-t@   2 root  admin    68B 11  4  2015 cores
drwxr-xr-x    4 root  wheel   136B  3 13 13:33 data
dr-xr-xr-x    3 root  wheel   4.2K  5 15 00:32 dev
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 etc -> private/etc
drwxrwxrwx    9 root  wheel   306B  3 10 14:18 home
-rw-r--r--@   1 root  wheel   313B  8 23  2015 installer.failurerequests
dr-xr-xr-x    2 root  wheel     1B  5 22 13:35 net
drwxrwxr-x@   3 root  wheel   102B  8  3  2015 opt
drwxr-xr-x@   6 root  wheel   204B 11  4  2015 private
drwxr-xr-x@  59 root  wheel   2.0K 11  4  2015 sbin
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 tmp -> private/tmp
drwxr-xr-x@  13 root  wheel   442B  9  8  2016 usr
lrwxr-xr-x@   1 root  wheel    11B 11  4  2015 var -> private/var

ls + 正则通配符 删选过滤

常用:

  1. 找出当前目录下以XXX后缀的所有文件 ls *.XXX, 可以和之前的命令选项搭配使用,下面是“找出当前目录下所有的.json"文件
[root@VM_140_109_centos ~]# ls -al *.log
-rw-r--r--. 1 root root 12754 12月 25 2014 install.log

3. grep 使用正则表达式搜索目标文件

使用: grep [OPTION] [FILE]

grep "关键字" "文件" , 在文件中寻找包含关键字的所有行

[root@VM_140_109_centos ~]# grep "rootfiles" install.log
Installing rootfiles-8.1-6.1.el6.noarch

-c (Count) 只显示统计匹配的行数

下方表示在"install.log"文件中,只有一行包含了"rootfiles"这个关键字,包含"centos"的有29行

[root@VM_140_109_centos ~]# grep "rootfiles" install.log -c
1

[root@VM_140_109_centos ~]# grep "centos" install.log -c
29

-A[-num] (After) 找出匹配关键字的行,并且把之后的-num行也显示出来

找出包含"rootfiles"的行,并把之后的1行也显示出来

[root@VM_140_109_centos ~]# grep "rootfiles" install.log -A1
Installing rootfiles-8.1-6.1.el6.noarch
*** FINISHED INSTALLING PACKAGES ***

可以看到多输出了之后的1行,就是

*** FINISHED INSTALLING PACKAGES ***

找出包含"nano"的行,并把之后的3行也显示出来


[root@VM_140_109_centos ~]# grep "nano" install.log -A3
Installing nano-2.0.9-7.el6.x86_64
Installing time-1.7-37.1.el6.x86_64
Installing attr-2.4.44-7.el6.x86_64
Installing scl-utils-20120927-8.el6.x86_64

可以看到多输出了之后的3行,就是

"Installing time-1.7-37.1.el6.x86_64
Installing attr-2.4.44-7.el6.x86_64
Installing scl-utils-20120927-8.el6.x86_64"

-B[-num] (Before) 与-A正好相反,这条命令找出匹配关键字的行,并且把之前的-num行也显示出来

找出包含"rootfiles"的行,并把之前的1行也显示出来

[root@VM_140_109_centos ~]# grep "rootfiles" install.log -B1
Installing atmel-firmware-1.3-7.el6.noarch
Installing rootfiles-8.1-6.1.el6.noarch

找出包含"nano"的行,并把之前的3行也显示出来

[root@VM_140_109_centos ~]# grep "nano" install.log -B3
Installing acl-2.2.49-6.el6.x86_64
Installing rsync-3.0.6-9.el6_4.1.x86_64
Installing ed-1.1-3.3.el6.x86_64
Installing nano-2.0.9-7.el6.x86_64

-num 直接加数字,表示除了这一行,把这行之前的-num行和之后的-num行都显示出来

把包含"install.log"中"nano"前后3行都显示出来

[root@VM_140_109_centos ~]# grep "nano" install.log -3
Installing acl-2.2.49-6.el6.x86_64
Installing rsync-3.0.6-9.el6_4.1.x86_64
Installing ed-1.1-3.3.el6.x86_64
Installing nano-2.0.9-7.el6.x86_64
Installing time-1.7-37.1.el6.x86_64
Installing attr-2.4.44-7.el6.x86_64
Installing scl-utils-20120927-8.el6.x86_64

-n 除了匹配的内容,将行号也打印出来

[root@VM_140_109_centos ~]# grep "nano" install.log  -n
278:Installing nano-2.0.9-7.el6.x86_64

可以看见:278为行号

将-n与之前的命令(grep "nano" install.log -3)组合使用

[root@VM_140_109_centos ~]# grep "nano" install.log -3 -n
275-Installing acl-2.2.49-6.el6.x86_64
276-Installing rsync-3.0.6-9.el6_4.1.x86_64
277-Installing ed-1.1-3.3.el6.x86_64
278:Installing nano-2.0.9-7.el6.x86_64
279-Installing time-1.7-37.1.el6.x86_64
280-Installing attr-2.4.44-7.el6.x86_64
281-Installing scl-utils-20120927-8.el6.x86_64

可以看到278行是匹配行,后面接的是":",其他的接的是"-"

-o 只显示匹配的内容

[root@VM_140_109_centos ~]# grep "nano" install.log  -o
nano

可以看见上面只显示了“nano"

上面的命令看起来没什么用,其实如果想提取一些信息-o命令还是有用的,比如提取"install.log"中所有以"yum"开头的单词,如下

[root@VM_140_109_centos ~]# grep "yum.*" install.log  -o
yum-metadata-parser-1.1.2-16.el6.x86_64
yum-plugin-fastestmirror-1.1.30-14.el6.noarch
yum-3.2.29-40.el6.centos.noarch
yum-plugin-security-1.1.30-14.el6.noarch
yum-utils-1.1.30-14.el6.noarch

-w 找出完全匹配单词的行

[root@VM_140_109_centos ~]# grep "yum" install.log   -w
Installing yum-metadata-parser-1.1.2-16.el6.x86_64
Installing yum-plugin-fastestmirror-1.1.30-14.el6.noarch
Installing yum-3.2.29-40.el6.centos.noarch
Installing yum-plugin-security-1.1.30-14.el6.noarch
Installing yum-utils-1.1.30-14.el6.noarch

如果带了-w ,像下面这样,只用"yu"去找,是找不到的,因为"yu"后面还有一个"m",字母还没有结束,grep认为这不是一个完整的单词

[root@VM_140_109_centos ~]# grep "yu" install.log   -w
[root@VM_140_109_centos ~]#

再试一下了一下,“yum-",以及"yum-uti"和"yum-utils",证明grep只会将开头是字母和结束是字母认为是一个单词(word),类似于"yum-"这种是找不到的

[root@VM_140_109_centos ~]# grep "yum-" install.log   -w

[root@VM_140_109_centos ~]# grep "yum-uti" install.log   -w

[root@VM_140_109_centos ~]# grep "yum-utils" install.log   -w
Installing yum-utils-1.1.30-14.el6.noarch

4. top 显示当前系统中各个进程的资源占用情况

使用 top [OPTION]

top

top命令不带任何参数就可以看见很多的系统参数

top - 00:28:40 up 31 days,  3:50,  1 user,  load average: 0.02, 0.01, 0.00
Tasks:  75 total,   1 running,  74 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.2%sy,  0.0%ni, 99.5%id,  0.1%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1020344k total,   956644k used,    63700k free,   401692k buffers
Swap:        0k total,        0k used,        0k free,   314400k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      20   0 19360  444  132 S  0.0  0.0   0:00.90 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:16.01 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:04.14 watchdog/0
    7 root      20   0     0    0    0 S  0.0  0.0   2:01.70 events/0
    8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.08 khelper
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm
   13 root      20   0     0    0    0 S  0.0  0.0   0:11.49 sync_supers
   14 root      20   0     0    0    0 S  0.0  0.0   0:10.12 bdi-default
   15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/0
   16 root      20   0     0    0    0 S  0.0  0.0   0:16.75 kblockd/0
   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpid
   18 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify
   

第一行

top - 00:28:40 up 31 days,  3:50,  1 user,  load average: 0.02, 0.01, 0.00
  • 00:28:40 当前的时间
  • 31 days 从开机到现在系统运行的时间
  • 1 user 系统中现在总共登录的用户数
  • load average: 0.02, 0.01, 0.00 系统截止到当前 1分钟 ,5 分钟, 15分钟 的复杂情况 。
    如果是1核的机器 , 1.00 代表cpu满载 ,2.00代表cpu超负荷2倍

第一行等同于命令 uptime

[root@VM_140_109_centos ~]# uptime
00:34:17 up 31 days, 3:56, 1 user, load average: 0.00, 0.00, 0.00


第二行


```bash
Tasks:  75 total,   1 running,  74 sleeping,   0 stopped,   0 zombie
  • 75 total 系统目前总共运行的进程数目
  • 1 running 系统目前正在运行的进程数目
  • 74 sleeping 系统目前正在休眠的进程数目
  • 0 stopped 系统目前处于停止状态的进程数目
  • 0 zombie 系统目前僵尸进程数目

第三行

Cpu(s):  0.1%us,  0.2%sy,  0.0%ni, 99.5%id,  0.1%wa,  0.0%hi,  0.0%si,  0.0%st

系统所有cpu的运行状态, 按1可以展开,详细查看每个cpu的情况

  • 0.1%us, user, 用户空间进程所占cpu百分比
  • 0.2%sy, system, 内核空间进程所占cpu百分比
  • 0.0%ni, nice, 改变过优先级的进程所占cpu百分比
  • 99.5%id, idle ,空闲cpu百分比
  • 0.1%wa, wait, 处于系统io等待进程所占cpu百分比
  • 0.0%hi, Hardware interrupt, 硬中断所占cpu百分比
  • 0.0%si, Software interrupt, 软中断所占cpu百分比
  • 0.0%st ,Steal Time ,是当 hypervisor 服务另一个虚拟处理器的时候,虚拟 CPU 等待实际 CPU 的时间的百分比,就是你的机器可能是一台物理机器虚拟化出来的其中一台虚拟机,你实际的cpu使用需要合这台物理机上的其他虚拟机竞争cpu资源(因为物理cpu核数是固定的,能力也有限)

第四行

Mem:   1020344k total,   956644k used,    63700k free,   401692k buffers

系统目前的内存使用状况

  • 1020344k total ,系统的总内存, 这里可以看到是以kb来计算 ,这里 1020344k /1024 = 996.4296875M ≈ 1G, 也就是1G内存
  • 956644k used ,系统目前使用的内存总量, 956644k /1024 = 934.22265625M ,使用了934M
  • 63700k free, 系统目前空闲内存, 63700k/1024=62.20703125M, 目前空闲62M
  • 401692k buffers, 系统缓存的内存量, 401692k / 1024 = 392.27734375M

第五行

Swap:        0k total,        0k used,        0k free,   314400k cached

系统目前交换区使用状况

  • 0k total, 交换区总量 0k
  • 0k used , 使用的交换区总量 0k
  • 0k free, 空闲的交换区总量 0k
  • 314400k cached, 缓冲的交换区总量 314400k /1024 = 307.03125M

再往下可以看到 ,系统目前运行进程的状况

  • PID 进程id
  • USER 进程拥有者
  • PR 进程优先级
  • NI NICE值, 负值表示高优先级,正值表示低优先级
  • VIRT 使用的虚拟内存总量, 以kb计算,VIRT=SWAP+RES
  • RES 进程使用的、未被换出的物理内存大小,以kb计算,RES=CODE+DATA
  • SHR 共享内存大小 以kb计算
  • S 进程状态。D=不可中断的睡眠状态 R=运行 S=睡眠 T=跟踪/停止 Z=僵尸进程
  • %CPU 距离上次更新到现在cpu的使用占比
  • %MEM 进程使用的物理内存占比
  • TIME+ 进程使用cpu总共的时间
  • COMMAND 进程名称(命令名/命令行)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,560评论 4 361
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,104评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,297评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,869评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,275评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,563评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,833评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,543评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,245评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,512评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,011评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,359评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,006评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,062评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,825评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,590评论 2 273
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,501评论 2 268

推荐阅读更多精彩内容

  • Ubuntu的发音 Ubuntu,源于非洲祖鲁人和科萨人的语言,发作 oo-boon-too 的音。了解发音是有意...
    萤火虫de梦阅读 98,505评论 9 468
  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 12,016评论 2 34
  • 学车科二挂了,本来一起的一批人都分道扬镳了,和下一批学员在一起,这一群人可没有我之前那一批学车的团结友爱啊,直接无...
    小县城生活日记阅读 196评论 0 0
  • 傻傻的我到底是该同情呢,还是该庆幸 从小学到现在,每次的学生工作都很难做,自己完全是出力不讨好 比如让别人做什么事...
    花儿的博文阅读 163评论 0 0
  • Redis 常用命令 键名列表 判断一个值是否存在 删除键 获得键值的数据类型 获取有效时间 字符串 赋值 取值 ...
    EdenPP阅读 223评论 0 1