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

相关文章

Debezium 与 Apache Kafka 的集成方式步骤详解

《Debezium与ApacheKafka的集成方式步骤详解》本文详细介绍了如何将Debezium与ApacheKafka集成,包括集成概述、步骤、注意事项等,通过KafkaConnect,D... 目录一、集成概述二、集成步骤1. 准备 Kafka 环境2. 配置 Kafka Connect3. 安装 D

Java中ArrayList和LinkedList有什么区别举例详解

《Java中ArrayList和LinkedList有什么区别举例详解》:本文主要介绍Java中ArrayList和LinkedList区别的相关资料,包括数据结构特性、核心操作性能、内存与GC影... 目录一、底层数据结构二、核心操作性能对比三、内存与 GC 影响四、扩容机制五、线程安全与并发方案六、工程

ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法

《ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法》本文介绍了Elasticsearch的基本概念,包括文档和字段、索引和映射,还详细描述了如何通过Docker... 目录1、ElasticSearch概念2、ElasticSearch、Kibana和IK分词器部署

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

Linux流媒体服务器部署流程

《Linux流媒体服务器部署流程》文章详细介绍了流媒体服务器的部署步骤,包括更新系统、安装依赖组件、编译安装Nginx和RTMP模块、配置Nginx和FFmpeg,以及测试流媒体服务器的搭建... 目录流媒体服务器部署部署安装1.更新系统2.安装依赖组件3.解压4.编译安装(添加RTMP和openssl模块

C++ Primer 多维数组的使用

《C++Primer多维数组的使用》本文主要介绍了多维数组在C++语言中的定义、初始化、下标引用以及使用范围for语句处理多维数组的方法,具有一定的参考价值,感兴趣的可以了解一下... 目录多维数组多维数组的初始化多维数组的下标引用使用范围for语句处理多维数组指针和多维数组多维数组严格来说,C++语言没

Spring Cloud LoadBalancer 负载均衡详解

《SpringCloudLoadBalancer负载均衡详解》本文介绍了如何在SpringCloud中使用SpringCloudLoadBalancer实现客户端负载均衡,并详细讲解了轮询策略和... 目录1. 在 idea 上运行多个服务2. 问题引入3. 负载均衡4. Spring Cloud Load

linux下多个硬盘划分到同一挂载点问题

《linux下多个硬盘划分到同一挂载点问题》在Linux系统中,将多个硬盘划分到同一挂载点需要通过逻辑卷管理(LVM)来实现,首先,需要将物理存储设备(如硬盘分区)创建为物理卷,然后,将这些物理卷组成... 目录linux下多个硬盘划分到同一挂载点需要明确的几个概念硬盘插上默认的是非lvm总结Linux下多