linux:du和df区别

文章目录

  • [1. 概述](#1. 概述)
  • [2. du 命令](#2. du 命令)
  • [2. df 命令](#2. df 命令)
  • [3. 区别总结](#3. 区别总结)

1. 概述

dudf 都是 Linux 系统中用于查看磁盘空间使用情况的命令,但它们的功能和用法有所不同。

2. du 命令

du 是 "disk usage" 的缩写,用于显示文件或目录的磁盘使用情况。du 命令用于查看指定文件或目录的磁盘空间使用情况,可以递归地查看目录下所有文件和子目录的大小。

详细用法查看这里

bash 复制代码
du [OPTION]... [FILE]...

常用OPTION

  • -h:以人类可读的格式显示磁盘使用量,如 KB、MB、GB 等。
  • -s:显示指定目录的总大小,而不显示其子目录的大小。
  • -c:显示总计磁盘使用量。
  • -a:显示所有文件和目录的大小,包括隐藏文件。
  • -k-m-g:以 KB、MB、GB 等单位显示磁盘使用量。

2. df 命令

df 是 "disk free" 的缩写,用于显示文件系统的磁盘空间使用情况。df 命令用于查看系统中所有挂载的文件系统的磁盘空间使用情况,包括每个文件系统的总大小、已用空间、可用空间以及文件系统类型等信息。

bash 复制代码
df [OPTION]... [FILE]...

[OPTION]:
  -a, --all             include pseudo, duplicate, inaccessible file systems
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
  -h, --human-readable  print sizes in powers of 1024 (e.g., 1023M)
  -H, --si              print sizes in powers of 1000 (e.g., 1.1G)
  -i, --inodes          list inode information instead of block usage
  -k                    like --block-size=1K
  -l, --local           limit listing to local file systems
      --no-sync         do not invoke sync before getting usage info (default)
      --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                               or print all fields if FIELD_LIST is omitted.
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
      --total           elide all entries insignificant to available space,
                          and produce a grand total
  -t, --type=TYPE       limit listing to file systems of type TYPE
  -T, --print-type      print file system type
  -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
  -v                    (ignored)
      --help     display this help and exit
      --version  output version information and exit

常用OPTION

  • -h:以人类可读的格式显示磁盘空间信息,如 KB、MB、GB 等。
  • -T:显示文件系统类型。
  • -t:仅显示指定类型的文件系统,如 ext4、tmpfs 等。
  • -i:显示 inode 的使用情况。

3. 区别总结

dudf 是两个不同的命令,用于查看不同层次的磁盘空间使用情况。

  • du 用于查看指定文件或目录的磁盘使用情况,而 df 用于查看系统中所有挂载的文件系统的磁盘空间使用情况。
  • du 只显示指定文件或目录的大小,而 df 显示文件系统的总大小、已用空间、可用空间等信息。
  • du 是针对文件或目录的,而 df 是针对文件系统的。
相关推荐
糖果店的幽灵13 分钟前
大模型测评DeepEval快速入门-RAG指标详解
数据库·人工智能·langgraph·大模型测评·deepeval
乱世刀疤15 分钟前
Claude Code提高工作效率案例:自动化分析工作流程时效性,缩短工单流转时长
运维·自动化
AOwhisky18 分钟前
云原生 DevOps 工具链从入门到实战(第二期)——Jenkins安装与基础配置——CICD核心引擎
linux·运维·ci/cd·云原生·jenkins·devops
盐焗鹌鹑蛋30 分钟前
【Linux】基础开发工具yum和vim
linux·运维·vim
AOwhisky38 分钟前
Linux(CentOS)系统管理入门笔记(第十四期)——计划任务与进程调度管理:atcron 与 nicechrt
linux·运维·笔记·centos·云计算·进程调度·计划任务
小莫分享1 小时前
sshw:用交互搜索和 Web 配置高效管理 SSH Server
linux·运维·golang·开源·ssh
whn19771 小时前
oracle的节点2无法启动asm实例 提示PMON terminating the instance due to error 481
数据库·oracle·wpf
fthux1 小时前
GitHub Actions自动化运维实战:构建高效可靠的CI/CD流水线
运维·自动化·github
流浪0011 小时前
Linux系统22:——文件(六):目标文件与ELF深度解析:从编译到加载的全景揭秘
linux·运维·服务器
MrDJun1 小时前
长期稳定跑网页监控:TLS 指纹、代理选路与请求节流的工程实践
运维·爬虫·python·网络协议·网站监控