There are several ways of checking your Linux system disk space. You could use a third-party app that shows the available disk space or do it by command-line way via the Linux Terminal.
In this guide, we are going to show you the best command-line ways of finding the disk space alongside some tips and tricks.
You can check disk space using du and df commands. Let’s discuss each of these commands with examples.
Method 1: Checking the disk space using du command
The du command in Linux is a short cut for Disk Usage. Using the du command, you can check your directories disk usage.
Syntax:
du [OPTION]... [FILE]...
Example 1. Find out disk usage on a specific directory and display the disk size in a human-readable format.
du -h /home/hendadel
Example 2. Check disk usage and sort by top 5 directories that are using most disk space.
du -a /home | sort -n -r | head -n 5
Method 2: Checking disk usage via the df command
The df is another powerful command you can use for fetching the disk space summary in a variety of ways.
Syntax:
df [OPTIONS]... FILESYSTEM...
Example 1. Display the Linux disk space usage for the file system.
df
Example 2. The df command has several options that you can use to determine your Linux file system disk usage. Use the following command to display the df command help.
df --help
Example 3. Display all the information for the disk space usage on all the file systems.
df -a
Example 4. Display the disk space usage for the file system in a human-readable format.
df -h
Example 5. To fetch the data just for the home file system only, use the following command:
df -hT /home/
Example 6. Check disk space usage for all drivers and show specific columns.
df -H --output=size,used,avail
Example 7. Display the disk space usage for the file system in bytes.
df -k
Example 8. The same thing, but in megabytes.
df -m
Example 9. Display disk space usage for the file system alongside its type.
df -T
I hope you enjoyed this tutorial in figuring out du and df command usage scenarios. To see all the available df command options, you can use man df or man du in your terminal.