有几个常用的命令可以查看 Linux 系统的内存使用情况:
1. free: 这个命令可以显示系统当前空闲、使用中的物理内存和交换分区的信息。
```
$ free -h
total used free shared buff/cache available
Mem: 7.8G 2.1G 4.4G 320M 1.3G 5.3G
Swap: 2.0G 0B 2.0G
```
2. top: 这个命令可以动态显示系统当前的进程信息,包括各个进程占用的内存大小。可以按内存使用量排序查看哪些进程占用内存较多。
```
$ top
Tasks: 171 total, 1 running, 170 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.7 us, 0.3 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7924.2 total, 2294.4 free, 2101.1 used, 3528.7 buff/cache
MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 5462.3 avail Mem
```
3. vmstat: 这个命令可以查看内存的使用情况以及一些系统性能指标。
```
$ vmstat
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 0 4500972 291028 1496424 0 0 4 9 0 0 1 0 99 0 0
```
4. htop: 这个工具提供了更加直观的进程监控界面,包括内存使用情况。需要自行安装。
这些命令都能提供Linux系统内存使用的详细信息,可以根据需求选择使用。