free命令——显示系统内存使用情况

free命令的功能是显示系统内存使用情况,包含物理内存和交换内存的总量、使用量和空闲量。

语法格式:free [选项]

常用选项及含义

|--------|---------------------------|
| 选项 | 含义 |
| -b | 以字节B为单位显示内存和交换内存的容量使用情况 |
| -k | 以KB为单位显示内存和交换内存的容量使用情况 |
| -m | 以MB为单位显示内存和交换内存的容量使用情况 |
| -g | 以GB为单位显示内存和交换内存的容量使用情况 |
| -h | 以易读且合适的单位显示内存和交换内存的容量使用情况 |
| -s | 每隔N秒显示内存和交换内存容量使用情况 |
| -t | 显示内存和交换内存容量大小的和 |

实例演练

1、以默认单位显示内存使用情况:

bash 复制代码
[root@host1 ~]# free
               total        used        free      shared  buff/cache   available
Mem:        15785284     6366528     6617340       11708     2801416     9098416
Swap:        1048572           0     1048572

各列含义说明如下:

  • total:总量
  • used:已使用量
  • free:空闲量
  • shared:进程共享量
  • buff/cache:缓冲/缓存量
  • available:可用物理内存

2、以MB为单位显示内存使用情况:

bash 复制代码
[root@host1 ~]# free -m
               total        used        free      shared  buff/cache   available
Mem:           15415        6219        6459          11        2735        8882
Swap:           1023           0        1023

3、以易读且合适的单位显示内存使用情况:

bash 复制代码
[root@host1 ~]# free -h
               total        used        free      shared  buff/cache   available
Mem:            15Gi       6.1Gi       6.3Gi        11Mi       2.7Gi       8.7Gi
Swap:          1.0Gi          0B       1.0Gi

4、每隔18秒以易读且合适的单位显示内存使用情况:

bash 复制代码
[root@host1 ~]# free -hs 18
               total        used        free      shared  buff/cache   available
Mem:            15Gi       6.1Gi       6.3Gi        11Mi       2.7Gi       8.7Gi
Swap:          1.0Gi          0B       1.0Gi

               total        used        free      shared  buff/cache   available
Mem:            15Gi       6.1Gi       6.3Gi        11Mi       2.7Gi       8.7Gi
Swap:          1.0Gi          0B       1.0Gi
相关推荐
likfishdn7 分钟前
Linux的文件与目录管理
linux·运维·服务器
渲染101专业云渲染8 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
chian-ocean26 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=28 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
橘子味的茶二38 分钟前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos