這個 df 命令 用於展示 數量磁盤空間 它在您的文件系統上是免費的。例如, df 第一次調用不帶參數。默認操作是以塊為單位顯示已用和可用文件空間。在這種特殊情況下,塊大小為 1024 字節,如輸出所示。

這篇文章解釋瞭如何使用它 df 命令 通過一些簡單的例子。

使用 df 命令的示例

如果 df 命令 不帶參數或選項運行可提供有關所有已掛載文件系統的信息。

$ df

以人類可讀尺寸打印

使用-H” 選項 df 命令,它以人類可讀的格式打印尺寸。我的意思是以 GB、MB 等為單位輸出大小。

以 MB 為單位顯示文件系統信息

使用 -h 選項 一起 df 命令 show 顯示所有文件系統統計信息(以 GB 為單位)

$ df -h

以 MB 為單位顯示文件系統信息

使用 -m 選項 一起 df 命令 show 顯示所有文件系統統計信息 (MB)。

$ df -m

示例輸出:

df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/sda5          23339  4872     17260  23% /
none                   1     0         1   0% /sys/fs/cgroup
udev                1804     1      1804   1% /dev
tmpfs                371     2       369   1% /run
none                   5     0         5   0% /run/lock
none                1851     2      1850   1% /run/shm
none                 100     1       100   1% /run/user
/dev/sda7          59733  5474     51203  10% /home

顯示所有掛載的文件系統,包括虛擬文件系統

利用 -一種 選項 什麼時候 df 命令打印所有文件系統,包括虛擬文件系統。

$ df -a

示例輸出:

$ df -a
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda5       23899004  4988564  17673400  23% /
proc                   0        0         0    - /proc
sysfs                  0        0         0    - /sys
none                   4        0         4   0% /sys/fs/cgroup
none                   0        0         0    - /sys/fs/fuse/connections
none                   0        0         0    - /sys/kernel/debug
none                   0        0         0    - /sys/kernel/security
udev             1847220        4   1847216   1% /dev
devpts                 0        0         0    - /dev/pts
tmpfs             378968     1232    377736   1% /run
none                5120        0      5120   0% /run/lock
none             1894828     1136   1893692   1% /run/shm
none              102400       16    102384   1% /run/user
none                   0        0         0    - /sys/fs/pstore
/dev/sda7       61165596  5601496  52433940  10% /home
binfmt_misc            0        0         0    - /proc/sys/fs/binfmt_misc
systemd                0        0         0    - /sys/fs/cgroup/systemd
gvfsd-fuse             0        0         0    - /run/user/1000/gvfs
/dev/sda2       51097596 38579520  12518076  76% /media/rasho/D056F85856F840B0
/dev/sda3      102399996  1656392 100743604   2% /media/rasho/Podaci

列出 inode

使用 -i 選項 一起 df 命令,打印我文件系統節點信息.

$ df -ih

示例輸出:

$ df -i
Filesystem        Inodes  IUsed     IFree IUse% Mounted on
/dev/sda5        1525920 168952   1356968   12% /
none              473707      2    473705    1% /sys/fs/cgroup
udev              461805    518    461287    1% /dev
tmpfs             473707    541    473166    1% /run
none              473707      1    473706    1% /run/lock
none              473707     10    473697    1% /run/shm
none              473707     16    473691    1% /run/user
/dev/sda7        3899392   7463   3891929    1% /home

顯示文件系統類型

如果您希望文件系統類型出現在輸出中,請使用 -T 選項

$ df -T

輸出:

$ df -T
Filesystem     Type     1K-blocks     Used Available Use% Mounted on
/dev/sda5      ext4      23899004  4988568  17673396  23% /
none           tmpfs            4        0         4   0% /sys/fs/cgroup
udev           devtmpfs   1847220        4   1847216   1% /dev
tmpfs          tmpfs       378968     1232    377736   1% /run
none           tmpfs         5120        0      5120   0% /run/lock
none           tmpfs      1894828     1136   1893692   1% /run/shm
none           tmpfs       102400       16    102384   1% /run/user
/dev/sda7      ext4      61165596  5602352  52433084  10% /home

您還可以顯示屬於特定類型的文件系統(這裡,文件系統類型表示 ext2、ext3、ext4、tmpfs、sysfs 等)。例如,以下命令僅顯示 ext4 文件系統類型。

$ df -t ext4

輸出:

$ df -t ext4
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda5       23899004 4988568  17673396  23% /
/dev/sda7       61165596 5603104  52432332  10% /home

顯示有​​關 /home 文件系統的信息

要查看 /home 文件系統類型,請運行以下命令:

$ df -hT /home

輸出:

$ df -hT /home
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sda7      ext4   59G  5.4G   51G  10% /home

目前為止就這樣了。有關詳細信息,請參閱 df 命令的手冊頁或幫助系統。

$ 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  scale sizes by SIZE before printing them.  E.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes.
                           See SIZE format below.
      --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