Linux df Command Examples

The df command in Linux is used to report the amount of disk space used and available on file systems. Below are 10 examples demonstrating various uses of the df command with detailed explanations.

1. Display Disk Usage in Default Format

Shows the disk space usage for all mounted file systems in 1K-blocks by default.

df

Example Output:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 10229760 5120000 5120000 50% /

2. Display in Human-Readable Format

Displays sizes in powers of 1024 (e.g., KB, MB, GB) for easier reading.

df -h

Example Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.8G 4.9G 4.9G 50% /

3. Include File System Type

Shows the type of each file system along with usage information.

df -T

Example Output:
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext4 10229760 5120000 5120000 50% /

4. Check Usage for a Specific Directory

Reports disk usage for the file system containing the specified directory.

df /home

Example Output:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 20459520 10240000 10240000 50% /home

5. Display Inode Usage

Shows inode (index node) usage instead of block usage.

df -i

Example Output:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 655360 10000 645360 2% /

6. Custom Output Columns

Allows specifying which columns to display in the output.

df --output=source,size,used,avail,pcent,target

Example Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 10229760 5120000 5120000 50% /

7. Include All File Systems

Displays information for all file systems, including dummy ones like proc and sysfs.

df -a

Example Output:
Includes additional entries like proc, sysfs, etc., with 0 blocks.

8. Display in Kilobytes

Forces output in kilobytes (1K-blocks).

df -k

Example Output:
Same as default df, showing sizes in 1K-blocks.

9. Display in Megabytes

Displays sizes in megabytes.

df -m

Example Output:
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/sda1 9990 5000 5000 50% /

10. Display Grand Total

Shows a grand total line at the end summing up all file systems.

df --total

Example Output:
Filesystem 1K-blocks Used Available Use% Mounted on
... (file systems) ...
total 30689280 15360000 15360000 50% -

Note: The output of these commands depends on your system's mounted file systems and usage. Use man df for more options and details.