Linux df command
The df
command in Linux is used to display the amount of disk space available and used on the file systems. It shows the available and used space on mounted filesystems, helping users monitor disk usage.
Basic Syntax:
Commonly Used Options:
-h
: Human-readable format (displays sizes in KB, MB, GB, etc.).-T
: Show the filesystem type.-a
: Include all file systems, even ones that are 0 bytes in size.-t
<type>: Show only filesystems of the specified type.-l
: Show only local filesystems (exclude network-mounted file systems).-i
: Show inode information (useful for checking inode usage).
Basic Usage:
Example Output:
Explanation of Output:
- Filesystem: The name of the filesystem or device (e.g.,
/dev/sda1
,/dev/sdb1
,tmpfs
). - 1K-blocks: The total size of the filesystem in 1K blocks.
- Used: The amount of space used on the filesystem.
- Available: The amount of available space left on the filesystem.
- Use%: The percentage of used space on the filesystem.
- Mounted on: The mount point (directory where the filesystem is mounted) in the system (e.g.,
/
,/mnt/data
).
Example with -h
(Human-readable format):
Sample Output:
- The output is now in human-readable format (MB, GB) instead of 1K blocks, making it easier to understand the disk usage.
Example with -T
(Filesystem type):
Sample Output:
- The
-T
option shows the type of each filesystem (e.g.,ext4
,tmpfs
).
Example with -i
(Inode information):
Sample Output:
- Inodes: Filesystem inodes represent individual files and directories.
- IUsed: Number of inodes in use.
- IFree: Number of free inodes available.
- IUse%: Percentage of used inodes on the filesystem.
Example with -a
(Include all filesystems):
Sample Output:
- The
-a
option includes all filesystems, including the CD-ROM (/dev/sr0
), even if their space is fully used (100%).
Example with -t <type>
(Filter by filesystem type):
Sample Output:
- The
-t ext4
option filters the output to show only filesystems of typeext4
.
Example with -l
(Local filesystems only):
Sample Output:
- The
-l
option filters out network-mounted file systems (such as NFS, CIFS, etc.) and only shows local filesystems.
Conclusion:
The df
command provides an overview of disk space usage, which is essential for monitoring storage on a Linux system. By using options like -h
, -T
, -i
, and others, you can customize the output to get more detailed information or to filter specific types of filesystems. It's a very useful tool for ensuring you have enough disk space and for troubleshooting disk space issues.