Using the df command on Linux
The df command provides information on file system usage, but includes quite a few options. This post examines the differences and makes some suggestions about when you should use which of the two commands.
The df command stands for “disk free” and, as that name suggests, it focuses on how much free disk space is available with a clear report like this one:
$ df Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 4096 0 4096 0% /dev tmpfs 1939948 0 1939948 0% /dev/shm tmpfs 775980 1688 774292 1% /run efivarfs 64 11 48 19% /sys/firmware/efi/efivars /dev/sda3 13974528 7045364 6330668 53% / tmpfs 1939948 16 1939932 1% /tmp /dev/sda3 13974528 7045364 6330668 53% /home /dev/sda2 996780 305840 622128 33% /boot /dev/sda1 613160 17780 595380 3% /boot/efi tmpfs 387988 128 387860 1% /run/user/1000 tmpfs 387988 40 387948 1% /run/user/1001
The default, as you can see from the above output, reports in one kilobyte blocks (1,024 bytes per block) and all file systems are listed. You can ask the command to report on a single file system like this:
$ df /dev/sda3 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 13974528 7044600 6331272 53% /
You can also request the information by the name of the mount point. This might make the command a tad easier.
$ df /home Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 13974528 7044600 6331272 53% /home
One of the nicest options for this command is to request the data you want to see in a human-friendly format. This would be analogous to telling your old friend that you’re about to celebrate your 17th anniversary, you expect to take two weeks off to celebrate, and you’ll be driving 7 hours to get to the resort where you plan to stay. Reporting all these events in the same unit of time unit would be much harder to communicate. Here’s an example of the report shown above in the human-readable format:
$ df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 758M 1.7M 757M 1% /run efivarfs 64K 11K 48K 19% /sys/firmware/efi/efivars /dev/sda3 14G 6.8G 6.1G 53% / tmpfs 1.9G 16K 1.9G 1% /tmp /dev/sda3 14G 6.8G 6.1G 53% /home /dev/sda2 974M 299M 608M 33% /boot /dev/sda1 599M 18M 582M 3% /boot/efi tmpfs 379M 128K 379M 1% /run/user/1000 tmpfs 379M 40K 379M 1% /run/user/1001
The df command also provides some other useful options. To report on file system type, for example, you can run a command like this one: