Table of Contents
1. Check file system disk space usage" >1. Check file system disk space usage
2. Display disk space usage information of all file systems" >2. Display disk space usage information of all file systems
3. Display disk space usage in human-readable format" >3. Display disk space usage in human-readable format
4. Display /home file system information" >4. Display /home file system information
5. Display file system information in bytes" >5. Display file system information in bytes
6. Display file system information in MB units" >6. Display file system information in MB units
7. 以 GB 为单位显示文件系统信息" >7. 以 GB 为单位显示文件系统信息
8. 显示文件系统 inode" >8. 显示文件系统 inode
9. 显示文件系统类型" >9. 显示文件系统类型
10. 包括某些文件系统类型" >10. 包括某些文件系统类型
11. 排除某些文件系统类型" >11. 排除某些文件系统类型
12. 显示 df 命令的信息。" >12. 显示 df 命令的信息。
Home System Tutorial LINUX 12 useful df commands to check disk space in linux

12 useful df commands to check disk space in linux

Feb 12, 2024 pm 02:30 PM
linux linux tutorial linux system linux command shell script Getting started with linux linux learning

1. Check file system disk space usage

This df command displays the device name, total number of blocks, total disk space, used disk space, free disk space, and mount point information on the file system.

linux 中检查磁盘空间的 12 个有用的 df 命令

[root@local ~]# df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23185840  51130588  32% /
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm
Copy after login

2. Display disk space usage information of all file systems

Same as above, but it also displays information about the virtual file system and all file system disk usage and its memory usage.

[root@local ~]# df -a

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23186116  51130312  32% /
proc                         0         0         0   -  /proc
sysfs                        0         0         0   -  /sys
devpts                       0         0         0   -  /dev/pts
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm
none                         0         0         0   -  /proc/sys/fs/binfmt_misc
sunrpc                       0         0         0   -  /var/lib/nfs/rpc_pipefs
Copy after login

3. Display disk space usage in human-readable format

Have you noticed that the above command displays information in bytes, which is not readable at all, because we are used to reading sizes in megabytes, gigabytes, etc., which is easy to understand and remember.

This df command provides an option to display dimensions in Human Readable format by using '-h' (print the result in human readable format ( For example, 1K 2M 3G)).

[root@local ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p2      75G   23G   49G  32% /
/dev/cciss/c0d0p5      24G   22G  1.2G  95% /home
/dev/cciss/c0d0p3      29G   25G  2.6G  91% /data
/dev/cciss/c0d0p1     289M   22M  253M   8% /boot
tmpfs                 252M     0  252M   0% /dev/shm
Copy after login
Copy after login

4. Display /home file system information

View unique device information/homeUse the following command for the file system in human-readable format.

[root@local ~]# df -hT /home

Filesystem  Type    Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p5 ext3     24G   22G  1.2G  95% /home
Copy after login

5. Display file system information in bytes

Display all file system information and usage 1024-byte blocks, use option '-k' (e.g. --block-size=1K) as follows.

[root@local ~]# df -k

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23187212  51129216  32% /
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm
Copy after login

6. Display file system information in MB units

Display all file system usage information MB(Mega Byte) Use this option as -m.

[root@local ~]# df -m

Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2        76525     22644     49931  32% /
/dev/cciss/c0d0p5        24217     21752      1215  95% /home
/dev/cciss/c0d0p3        29057     24907      2651  91% /data
/dev/cciss/c0d0p1          289        22       253   8% /boot
tmpfs                      252         0       252   0% /dev/shm
Copy after login

7. 以 GB 为单位显示文件系统信息

显示所有文件系统统计信息GB(Gigabyte) 将该选项用作 ‘df -h‘。

[root@local ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p2      75G   23G   49G  32% /
/dev/cciss/c0d0p5      24G   22G  1.2G  95% /home
/dev/cciss/c0d0p3      29G   25G  2.6G  91% /data
/dev/cciss/c0d0p1     289M   22M  253M   8% /boot
tmpfs                 252M     0  252M   0% /dev/shm
Copy after login
Copy after login

8. 显示文件系统 inode

使用 -i开关将显示文件系统的已使用 inode 数量及其百分比信息。

[root@local ~]# df -i

Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/cciss/c0d0p2    20230848  133143 20097705    1% /
/dev/cciss/c0d0p5    6403712  798613 5605099   13% /home
/dev/cciss/c0d0p3    7685440 1388241 6297199   19% /data
/dev/cciss/c0d0p1      76304      40   76264    1% /boot
tmpfs                  64369       1   64368    1% /dev/shm
Copy after login

9. 显示文件系统类型

如果您注意到上述所有命令输出,您将看到结果中没有提到Linux 文件系统类型。要检查系统的文件系统类型,请使用选项 T。它将显示文件系统类型以及其他信息。

[root@local ~]# df -T

Filesystem  Type   1K-blocks  Used      Available Use% Mounted on
/dev/cciss/c0d0p2 ext3    78361192  23188812  51127616  32%   /
/dev/cciss/c0d0p5 ext3    24797380  22273432  1243972   95%   /home
/dev/cciss/c0d0p3 ext3    29753588  25503792  2713984   91%   /data
/dev/cciss/c0d0p1 ext3    295561     21531    258770    8%    /boot
tmpfs   tmpfs   257476         0    257476    0%   /dev/shm
Copy after login

10. 包括某些文件系统类型

如果要显示某些文件系统类型,请使用 -t 选项。例如下面的命令只会显示ext3文件系统。

[root@local ~]# df -t ext3

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23190072  51126356  32% /
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
Copy after login

11. 排除某些文件系统类型

如果要显示不属于的文件系统类型ext3键入使用选项作为 -x。例如,以下命令将只显示除ext3.

[root@local ~]# df -x ext3

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                   257476         0    257476   0% /dev/shm
Copy after login

12. 显示 df 命令的信息。

使用'--help‘ 开关将显示与df命令。

[root@local ~]# 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
  -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

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 bugs to .
Copy after login

The above is the detailed content of 12 useful df commands to check disk space in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

See all articles