df Command ExamplesThe 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.
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% /
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% /
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% /
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
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% /
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% /
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.
Forces output in kilobytes (1K-blocks).
df -k
Example Output:
Same as default df, showing sizes in 1K-blocks.
Displays sizes in megabytes.
df -m
Example Output:
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/sda1 9990 5000 5000 50% /
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.