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

相关文章

QT6中绘制UI的两种方法详解与示例代码

《QT6中绘制UI的两种方法详解与示例代码》Qt6提供了两种主要的UI绘制技术:​​QML(QtMeta-ObjectLanguage)​​和​​C++Widgets​​,这两种技术各有优势,适用于不... 目录一、QML 技术详解1.1 QML 简介1.2 QML 的核心概念1.3 QML 示例:简单按钮

使用Java将实体类转换为JSON并输出到控制台的完整过程

《使用Java将实体类转换为JSON并输出到控制台的完整过程》在软件开发的过程中,Java是一种广泛使用的编程语言,而在众多应用中,数据的传输和存储经常需要使用JSON格式,用Java将实体类转换为J... 在软件开发的过程中,Java是一种广泛使用的编程语言,而在众多应用中,数据的传输和存储经常需要使用j

一文详解PostgreSQL复制参数

《一文详解PostgreSQL复制参数》PostgreSQL作为一款功能强大的开源关系型数据库,其复制功能对于构建高可用性系统至关重要,本文给大家详细介绍了PostgreSQL的复制参数,需要的朋友可... 目录一、复制参数基础概念二、核心复制参数深度解析1. max_wal_seChina编程nders:WAL

Nginx路由匹配规则及优先级详解

《Nginx路由匹配规则及优先级详解》Nginx作为一个高性能的Web服务器和反向代理服务器,广泛用于负载均衡、请求转发等场景,在配置Nginx时,路由匹配规则是非常重要的概念,本文将详细介绍Ngin... 目录引言一、 Nginx的路由匹配规则概述二、 Nginx的路由匹配规则类型2.1 精确匹配(=)2

一文详解如何查看本地MySQL的安装路径

《一文详解如何查看本地MySQL的安装路径》本地安装MySQL对于初学者或者开发人员来说是一项基础技能,但在安装过程中可能会遇到各种问题,:本文主要介绍如何查看本地MySQL安装路径的相关资料,需... 目录1. 如何查看本地mysql的安装路径1.1. 方法1:通过查询本地服务1.2. 方法2:通过MyS

Mysql数据库中数据的操作CRUD详解

《Mysql数据库中数据的操作CRUD详解》:本文主要介绍Mysql数据库中数据的操作(CRUD),详细描述对Mysql数据库中数据的操作(CRUD),包括插入、修改、删除数据,还有查询数据,包括... 目录一、插入数据(insert)1.插入数据的语法2.注意事项二、修改数据(update)1.语法2.有

Nginx使用Keepalived部署web集群(高可用高性能负载均衡)实战案例

《Nginx使用Keepalived部署web集群(高可用高性能负载均衡)实战案例》本文介绍Nginx+Keepalived实现Web集群高可用负载均衡的部署与测试,涵盖架构设计、环境配置、健康检查、... 目录前言一、架构设计二、环境准备三、案例部署配置 前端 Keepalived配置 前端 Nginx

SQL Server中的PIVOT与UNPIVOT用法具体示例详解

《SQLServer中的PIVOT与UNPIVOT用法具体示例详解》这篇文章主要给大家介绍了关于SQLServer中的PIVOT与UNPIVOT用法的具体示例,SQLServer中PIVOT和U... 目录引言一、PIVOT:将行转换为列核心作用语法结构实战示例二、UNPIVOT:将列编程转换为行核心作用语

Python logging模块使用示例详解

《Pythonlogging模块使用示例详解》Python的logging模块是一个灵活且强大的日志记录工具,广泛应用于应用程序的调试、运行监控和问题排查,下面给大家介绍Pythonlogging模... 目录一、为什么使用 logging 模块?二、核心组件三、日志级别四、基本使用步骤五、快速配置(bas

使用animation.css库快速实现CSS3旋转动画效果

《使用animation.css库快速实现CSS3旋转动画效果》随着Web技术的不断发展,动画效果已经成为了网页设计中不可或缺的一部分,本文将深入探讨animation.css的工作原理,如何使用以及... 目录1. css3动画技术简介2. animation.css库介绍2.1 animation.cs