Linux df 命令使用详解

2024-05-07 02:38
文章标签 linux 使用 命令 详解 df

本文主要是介绍Linux df 命令使用详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

随时随地技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)

一、功能说明:显示磁盘的相关信息。

二、语法:df [-ahHiklmPT][--block-size=<区块大小>][-t <文件系统类型>][-x <文件系统类型>][--help][--no-sync][--sync][--version][文件或设备]


三、补充说明:df可显示磁盘的文件系统与使用情形。

四、具体事例:

1、-a或--all   包含全部的文件系统。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -a
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1      41282880 1808452  37377380   5% /
proc                   0       0         0    - /proc
sysfs                  0       0         0    - /sys
devpts                 0       0         0    - /dev/pts
tmpfs             509164       0    509164   0% /dev/shm
none                   0       0         0    - /proc/sys/fs/binfmt_misc
none                   0       0         0    - /proc/xen

2、--block-size=<区块大小>   以指定的区块大小来显示区块数目。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --block-size=10240
Filesystem     10K-blocks   Used Available Use% Mounted on
/dev/xvda1        4128288 180846   3737738   5% /
tmpfs               50917      0     50917   0% /dev/shm

3、-h或--human-readable   以可读性较高的方式来显示信息。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       40G  1.8G   36G   5% /
tmpfs           498M     0  498M   0% /dev/shm

4、-H或--si   与-h参数相同,但在计算时是以1000 Bytes为换算单位而非1024 Bytes。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -H
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       43G  1.9G   39G   5% /
tmpfs           522M     0  522M   0% /dev/shm

5、-i或--inodes   显示inode的信息。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -i
Filesystem      Inodes IUsed   IFree IUse% Mounted on
/dev/xvda1     2621440 48349 2573091    2% /
tmpfs           127291     1  127290    1% /dev/shm

6、-k或--kilobytes   指定区块大小为1024字节。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -k
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1      41282880 1808456  37377376   5% /
tmpfs             509164       0    509164   0% /dev/shm

7、-l或--local   仅显示本地端的文件系统。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -l
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1      41282880 1808456  37377376   5% /
tmpfs             509164       0    509164   0% /dev/shm

8、-m或--megabytes   指定区块大小为1048576字节。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/xvda1         40316  1767     36502   5% /
tmpfs                498     0       498   0% /dev/shm

9、--no-sync   在取得磁盘使用信息前,不要执行sync指令,此为预设值。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --no-sync
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1      41282880 1808460  37377372   5% /
tmpfs             509164       0    509164   0% /dev/shm

10、-P或--portability   使用POSIX的输出格式。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -P
Filesystem     1024-blocks    Used Available Capacity Mounted on
/dev/xvda1        41282880 1808460  37377372       5% /
tmpfs               509164       0    509164       0% /dev/shm

11、--sync   在取得磁盘使用信息前,先执行sync指令。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --sync
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1      41282880 1808460  37377372   5% /
tmpfs             509164       0    509164   0% /dev/shm

12、-t<文件系统类型>或--type=<文件系统类型>   仅显示指定文件系统类型的磁盘信息。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -t tmpfs
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs             509164     0    509164   0% /dev/shm

13、-T或--print-type   显示文件系统的类型。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -T
Filesystem     Type  1K-blocks    Used Available Use% Mounted on
/dev/xvda1     ext3   41282880 1808468  37377364   5% /
tmpfs          tmpfs    509164       0    509164   0% /dev/shm

14、-x<文件系统类型>或--exclude-type=<文件系统类型>   不要显示指定文件系统类型的磁盘信息。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -x tmpfs
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1      41282880 1808468  37377364   5% /

15、--direct      show statistics for a file instead of mount point

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --direct
Filesystem     1K-blocks    Used Available Use% File
/dev/xvda1      41282880 1808468  37377364   5% /
tmpfs             509164       0    509164   0% /dev/shm

16、 --total       produce a grand total

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --total
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1      41282880 1808468  37377364   5% /
tmpfs             509164       0    509164   0% /dev/shm
total           41792044 1808468  37886528   5%

17、--help   显示帮助

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.


Mandatory arguments to long options are mandatory for short options too.
  -a, --all             include dummy file systems
  -B, --block-size=SIZE  use SIZE-byte blocks
      --direct          show statistics for a file instead of mount point
      --total           produce a grand total
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
  -H, --si              likewise, but use powers of 1000 not 1024
  -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)
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
  -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


Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).


SIZE may be (or may be an integer optionally followed by) one of following:
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.


Report df bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'df invocation'

18、--version   显示版本信息。

[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --version
df (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


Written by Torbjörn Granlund, David MacKenzie, and Paul Eggert.

这篇关于Linux df 命令使用详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/966099

相关文章

Spring Boot 集成 Quartz并使用Cron 表达式实现定时任务

《SpringBoot集成Quartz并使用Cron表达式实现定时任务》本篇文章介绍了如何在SpringBoot中集成Quartz进行定时任务调度,并通过Cron表达式控制任务... 目录前言1. 添加 Quartz 依赖2. 创建 Quartz 任务3. 配置 Quartz 任务调度4. 启动 Sprin

Linux之计划任务和调度命令at/cron详解

《Linux之计划任务和调度命令at/cron详解》:本文主要介绍Linux之计划任务和调度命令at/cron的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux计划任务和调度命令at/cron一、计划任务二、命令{at}介绍三、命令语法及功能 :at

Linux下如何使用C++获取硬件信息

《Linux下如何使用C++获取硬件信息》这篇文章主要为大家详细介绍了如何使用C++实现获取CPU,主板,磁盘,BIOS信息等硬件信息,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录方法获取CPU信息:读取"/proc/cpuinfo"文件获取磁盘信息:读取"/proc/diskstats"文

Java使用SLF4J记录不同级别日志的示例详解

《Java使用SLF4J记录不同级别日志的示例详解》SLF4J是一个简单的日志门面,它允许在运行时选择不同的日志实现,这篇文章主要为大家详细介绍了如何使用SLF4J记录不同级别日志,感兴趣的可以了解下... 目录一、SLF4J简介二、添加依赖三、配置Logback四、记录不同级别的日志五、总结一、SLF4J

使用Python实现一个优雅的异步定时器

《使用Python实现一个优雅的异步定时器》在Python中实现定时器功能是一个常见需求,尤其是在需要周期性执行任务的场景下,本文给大家介绍了基于asyncio和threading模块,可扩展的异步定... 目录需求背景代码1. 单例事件循环的实现2. 事件循环的运行与关闭3. 定时器核心逻辑4. 启动与停

如何使用Nginx配置将80端口重定向到443端口

《如何使用Nginx配置将80端口重定向到443端口》这篇文章主要为大家详细介绍了如何将Nginx配置为将HTTP(80端口)请求重定向到HTTPS(443端口),文中的示例代码讲解详细,有需要的小伙... 目录1. 创建或编辑Nginx配置文件2. 配置HTTP重定向到HTTPS3. 配置HTTPS服务器

Java使用ANTLR4对Lua脚本语法校验详解

《Java使用ANTLR4对Lua脚本语法校验详解》ANTLR是一个强大的解析器生成器,用于读取、处理、执行或翻译结构化文本或二进制文件,下面就跟随小编一起看看Java如何使用ANTLR4对Lua脚本... 目录什么是ANTLR?第一个例子ANTLR4 的工作流程Lua脚本语法校验准备一个Lua Gramm

Java Optional的使用技巧与最佳实践

《JavaOptional的使用技巧与最佳实践》在Java中,Optional是用于优雅处理null的容器类,其核心目标是显式提醒开发者处理空值场景,避免NullPointerExce... 目录一、Optional 的核心用途二、使用技巧与最佳实践三、常见误区与反模式四、替代方案与扩展五、总结在 Java

Linux内核参数配置与验证详细指南

《Linux内核参数配置与验证详细指南》在Linux系统运维和性能优化中,内核参数(sysctl)的配置至关重要,本文主要来聊聊如何配置与验证这些Linux内核参数,希望对大家有一定的帮助... 目录1. 引言2. 内核参数的作用3. 如何设置内核参数3.1 临时设置(重启失效)3.2 永久设置(重启仍生效

使用Java将DOCX文档解析为Markdown文档的代码实现

《使用Java将DOCX文档解析为Markdown文档的代码实现》在现代文档处理中,Markdown(MD)因其简洁的语法和良好的可读性,逐渐成为开发者、技术写作者和内容创作者的首选格式,然而,许多文... 目录引言1. 工具和库介绍2. 安装依赖库3. 使用Apache POI解析DOCX文档4. 将解析