📂 Command: df (Disk Free)
The df command reports the amount of disk space used and available on your Linux filesystems. It’s your primary tool for making sure your partitions aren't hitting 100%.
1. The "Why"
On Arch Linux, you are the architect of your own system. Since you likely manage your own partitions (perhaps a separate /home or a specific EFI partition for rEFInd), you need to keep an eye on them.
- Prevent Crashes: If your
root(/) partition hits 100%, your system might fail to boot or behave erratically. - Monitor Backups: See how much space your Preader source code or e-book drafts are taking up on your drive.
- Check External Drives: Verify if a USB stick or external HDD is correctly mounted and how much room is left for your Android projects.
2. Basic Syntax
df [OPTIONS]
If you run just df, it will show sizes in 1-kilobyte blocks, which is very hard for humans to read. You will almost always use the "Human Readable" flag.
3. The "Must-Have" Flag: -h
The -h flag converts the output into Gigabytes (G) and Megabytes (M).
df -h
Understanding the Output Columns:
- Filesystem: The physical drive or partition (e.g.,
/dev/sda2). - Size: Total capacity.
- Used: Space currently occupied.
- Avail: Space remaining.
- Use%: The percentage used (if this is over 90%, it's time to clean up!).
- Mounted on: Where the partition is attached to your folder structure.
4. Practical Examples
A. Checking a Specific Partition
If you only care about your home folder:
df -h /home
B. Checking Filesystem Types
If you want to see which partitions are ext4, fat32, or btrfs:
df -hT
C. Excluding "Temp" Filesystems
Linux uses many "virtual" filesystems in RAM (like tmpfs). To hide these and only see your actual hard drive partitions:
df -h --total -x tmpfs -x devtmpfs
5. Pro-Tips
- Inodes: Sometimes a disk says it has space, but you can't create new files. This usually means you've run out of "inodes" (index nodes). You can check this with
df -i. - Total Sum: Use
df -h --totalto see a grand total at the bottom of the list. - Arch Linux Context: If you find your disk space disappearing unexpectedly, check your Pacman cache (
/var/cache/pacman/pkg/). It stores every package you've ever downloaded. You can clean it withsudo paccache -r.
6. Summary Reference
| Goal | Command |
|---|---|
| Check all disks (Readable) | df -h |
| Check a specific folder | df -h /path/to/folder |
| Show filesystem types | df -hT |
| Check Inodes | df -i |