Popular blog tags

free

root:~# free
              total        used        free      shared  buff/cache   available
Mem:        1008740      262812      170244        4164      575684      592980
Swap:             0           0           0

total : 总计屋里内存的大小

used : 已使用内存的大小

free : 可用内存的大小

shared : 多个进程共享的内存总额

buff/cache : 磁盘缓存大小

available : 可用内存大小 , 从应用程序的角度来说:available = free + buff/cache 

输入命令分类:

free    用KB为单位展示数据
free -m    用MB为单位展示数据
free -h     用GB为单位展示数据

top

root@vultr:~# top
top - 16:22:46 up 2 days, 23:56,  1 user,  load average: 0.00, 0.01, 0.00
Tasks: 115 total,   1 running,  77 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1008740 total,   171444 free,   261240 used,   576056 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   594540 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                
    1 root      20   0  160136   8884   6216 S  0.0  0.9   0:17.69 systemd                                
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.04 kthreadd                               
    4 root       0 -20       0      0      0 I  0.0  0.0   0:00.00 kworker/0:0H                           
    6 root       0 -20       0      0      0 I  0.0  0.0   0:00.00 mm_percpu_wq                           

 PID:进程的ID

      USER:进程所有者

       PR:进程的优先级别,越小越优先被执行

       NI:进程Nice值,代表这个进程的优先值

       VIRT:进程占用的虚拟内存

       RES:进程占用的物理内存

       SHR:进程使用的共享内存

      S:进程的状态。S表示休眠,R表示正在运行,Z表示僵死状态

       %CPU:进程占用CPU的使用

       %MEM:进程使用的物理内存和总内存的百分

       TIME+:该进程启动后占用的总的CPU时间,即占用CPU使用时间的累加值

       COMMAND:启动该进程的命令名称

cat /proc/meminfo

root@vultr:~# cat /proc/meminfo
MemTotal:        1008740 kB
MemFree:          169524 kB
MemAvailable:     592632 kB
Buffers:          122328 kB
Cached:           405400 kB
SwapCached:            0 kB
Active:           513544 kB
Inactive:         200596 kB
Active(anon):     184520 kB
Inactive(anon):     3384 kB
Active(file):     329024 kB
Inactive(file):   197212 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               288 kB
Writeback:             0 kB
AnonPages:        186432 kB
Mapped:           198668 kB
Shmem:              4164 kB
Slab:              85288 kB
SReclaimable:      48340 kB
SUnreclaim:        36948 kB
KernelStack:        3232 kB
PageTables:        11720 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      504368 kB
Committed_AS:    1181136 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      106352 kB
DirectMap2M:      942080 kB
DirectMap1G:           0 kB

ps aux --sort -rss

root:~# ps aux --sort -rss
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       394  0.0 19.4 354696 195980 ?       S<s  Apr23   1:00 /lib/systemd/systemd-journald
www-data   542  0.0  9.5 3012284 96096 ?       Ssl  Apr23   2:14 /usr/bin/dotnet

按照 pid,按照 rss 排序显示内容