回到手册索引

命令用途

df(disk free)是 Linux/Unix 系统中用于显示文件系统磁盘空间使用情况的命令,可快速查看磁盘剩余空间、挂载点及存储设备信息。

常用用法示例

  1. 默认显示所有文件系统的磁盘空间

    1
    2
    3
    4
    df
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/sda1 20970496 8563160 11307336 44% /
    tmpfs 817596 0 817596 0% /dev/shm

    显示所有已挂载文件系统的磁盘块数和使用百分比。

  2. 以易读格式显示(自动转换单位)

    1
    2
    3
    4
    df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda1 20G 8.2G 11G 44% /
    tmpfs 799M 0 799M 0% /dev/shm

    使用 -h 参数将容量转换为 GB/MB 等人类可读格式。

  3. 显示指定文件系统的信息

    1
    2
    3
    df /dev/sda1
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/sda1 20970496 8563160 11307336 44% /

    仅显示指定设备(如 /dev/sda1)的磁盘使用情况。

  4. 显示文件系统类型

    1
    2
    3
    df -T
    Filesystem Type 1K-blocks Used Available Use% Mounted on
    /dev/sda1 ext4 20970496 8563160 11307336 44% /

    通过 -T 参数显示文件系统类型(如 ext4、tmpfs)。

  5. 显示 inode 使用情况

    1
    2
    3
    df -i
    Filesystem Inodes IUsed IFree IUse% Mounted on
    /dev/sda1 1310720 23456 1287264 2% /

    使用 -i 参数查看 inode 的使用情况而非磁盘空间。

  6. 排除特定文件系统类型

    1
    2
    3
    df -x tmpfs
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/sda1 20970496 8563160 11307336 44% /

    通过 -x 参数排除 tmpfs 等指定类型的文件系统。

  7. 显示本地文件系统

    1
    2
    3
    df -l
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/sda1 20970496 8563160 11307336 44% /

    使用 -l 参数仅显示本地文件系统,忽略网络挂载。

  8. 输出特定字段(需指定列名)

    1
    2
    3
    df --output=source,size,pcent
    Filesystem 1K-blocks Use%
    /dev/sda1 20970496 44%

    通过 –output 自定义输出字段(source=设备名,size=总大小,pcent=使用百分比)。

常用参数选项

  • -h, –human-readable
    以 KB、MB、GB 为单位自动转换容量显示,提高可读性。
  • -T, –print-type
    显示文件系统类型(如 ext4、xfs)。
  • -i, –inodes
    显示 inode 使用情况而非磁盘空间。
  • -a, –all
    包含虚拟文件系统(如/proc、/sys)。
  • -t, –type=TYPE
    仅显示指定类型的文件系统(如 -t ext4)。
  • -x, –exclude-type=TYPE
    排除指定类型的文件系统。
  • -l, –local
    仅显示本地文件系统,忽略网络挂载。
  • –output=FIELD_LIST
    自定义输出字段(如 source,size,avail,pcent)。

原厂文档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
NAME

df - report file system space usage

SYNOPSIS

df [OPTION]... [FILE]...

DESCRIPTION

This manual page documents the GNU version of df. df displays the
amount of space available on the file system containing each file
name argument. If no file name is given, the space available on
all currently mounted file systems is shown. Space is shown in 1K
blocks by default, unless the environment variable POSIXLY_CORRECT
is set, in which case 512-byte blocks are used.

If an argument is the absolute file name of a device node
containing a mounted file system, df shows the space available on
that file system rather than on the file system containing the
device node. This version of df cannot show the space available
on unmounted file systems, because on most kinds of systems doing
so requires non-portable intimate knowledge of file system
structures.

OPTIONS

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 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

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).

The SIZE argument is an integer and optional unit (example: 10K is
10*1024). Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or
KB,MB,... (powers of 1000). Binary prefixes can be used, too:
KiB=K, MiB=M, and so on.

FIELD_LIST is a comma-separated list of columns to be included.
Valid field names are: 'source', 'fstype', 'itotal', 'iused',
'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and
'target' (see info page).

AUTHOR

Written by Torbjorn Granlund, David MacKenzie, and Paul Eggert.

REPORTING BUGS

GNU coreutils online help:
<https://www.gnu.org/software/coreutils/>
Report any translation bugs to
<https://translationproject.org/team/>

COPYRIGHT

Copyright © 2025 Free Software Foundation, Inc. License GPLv3+:
GNU GPL version 3 or later <https://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.

SEE ALSO

Full documentation <https://www.gnu.org/software/coreutils/df>
or available locally via: info '(coreutils) df invocation'

COLOPHON

This page is part of the coreutils (basic file, shell and text
manipulation utilities) project. Information about the project
can be found at ⟨http://www.gnu.org/software/coreutils/⟩. If you
have a bug report for this manual page, see
⟨http://www.gnu.org/software/coreutils/⟩. This page was obtained
from the tarball coreutils-9.6.tar.xz fetched from
⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2024-02-02. If you
discover any rendering problems in this HTML version of the page,
or you believe there is a better or more up-to-date source for the
page, or you have corrections or improvements to the information
in this COLOPHON (which is not part of the original manual page),
send a mail to man-pages@man7.org