当前位置:首页 > linux > 正文

linux查看剩余内存命令

  • linux
  • 2024-05-08 23:50:13
  • 7679

1. free 命令
free 命令显示系统中可用、已用和总内存数量。
free
示例输出:
total used free shared buff/cache available
Mem: 31Gi 23Gi 8Gi 68Mi 2.0Gi 9.7Gi
Swap: 15Gi 7.2Gi 7.8Gi
2. vmstat 命令
vmstat 命令显示内存统计信息,包括剩余内存量。
vmstat 1 2
第二列输出:
procs -----------memory---------- ---swap-- -----io---- -system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 10720 66576 10132 361160 0 0 0 0 23 10 3 3 93 1 0
0 1 10720 66576 10132 361160 0 0 0 0 22 9 4 3 93 0 0
其中,free 列显示剩余内存量(以 KB 为单位)。
3. top 命令
top 命令显示实时系统信息,其中包括内存使用情况。
top -d 1
第一行输出:
top - 18:50:21 up 23:26, 3 users, load average: 0.89, 0.64, 0.55
Tasks: 212 total, 1 running, 211 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.8 us, 2.1 sy, 0.0 ni, 94.8 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 32960 total, 25936 free, 4152 used, 2872 buff/cache
KiB Swap: 16384 total, 16384 free, 0 used. 45056 avail Mem
第四行显示:
KiB Mem 总内存、可用内存、已用内存、缓冲/缓存内存。
KiB Swap 总交换分区大小、可用交换分区大小、已用交换分区大小。