df
The df (disk free) command displays the amount of available disk space for file systems on which the invoking user has appropriate read access. It is the primary tool for quickly checking how much storage space is left on your partitions.
Basic Syntax
df [OPTIONS] [FILE]
If a file is specified, df shows the disk space of the file system containing that file.
Common Flags/Options
| Option | Description |
|---|---|
-h, --human-readable | Print sizes in powers of 1024 (e.g., 1023M, 2.0G). This is the most commonly used flag. |
-H, --si | Print sizes in powers of 1000 (e.g., 1.1G). |
-T, --print-type | Print the file system type (e.g., ext4, xfs, tmpfs). |
-i, --inodes | List inode information instead of block usage. Useful if you run out of inodes but still have space. |
-a, --all | Include dummy and duplicate file systems (often excluded by default). |
Real-world Examples
1. Check disk space in a readable format
This is the most standard usage. It lists all mounted file systems, their total size, used space, available space, percentage used, and mount point.
df -h
Output Example:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 20G 28G 42% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
2. Check the file system type
If you need to know if a partition is ext4, xfs, or something else, use -T.
df -Th
3. Check inode usage
Sometimes a disk isn't out of space (bytes), but out of inodes (the structures that store file metadata), usually due to millions of tiny files.
df -hi
4. Check the file system of a specific directory
If you want to know which partition a specific folder belongs to and how much space it has:
df -h /var/log