Linux provides several command-line tools to help you quickly check the available disk space on your system. These tools offer different levels of detail and functionality, allowing you to tailor the information to your specific needs.
The df
Command
The df
(Disk Free) command is one of the most commonly used tools for checking disk space usage. It displays the total size, used space, and available space for each mounted file system on your system.
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 20G 28G 43% /
tmpfs 16G 1.6M 16G 1% /run
/dev/sda2 477G 456G 21G 96% /home
The -h
option in the above command displays the sizes in human-readable format (e.g., gigabytes instead of bytes).
The du
Command
The du
(Disk Usage) command is used to estimate the file space usage of a directory or file. It provides more detailed information than df
, allowing you to analyze disk usage at the directory or file level.
$ du -h /var/log
4.0K /var/log/alternatives.log
4.0K /var/log/apt
12K /var/log/auth.log
8.0K /var/log/bootstrap.log
The -h
option in the above command displays the sizes in human-readable format.
Combining df
and du
By combining the df
and du
commands, you can get a more comprehensive understanding of your system's disk usage. For example, you can use du
to identify the directories or files consuming the most disk space, and then use df
to check the overall available space on the file system.