Check disk usage with df -h
In this step, you will learn how to check the disk space usage on your Linux system using the df
command. Understanding disk usage is crucial for managing your system and preventing issues caused by a full disk.
The df
command stands for "disk filesystem". It displays information about the total space, used space, and available space on mounted filesystems.
Let's start by running the basic df
command in your terminal:
df
You will see output similar to this:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 XXXXXXXX XXXXXXXX XXXXXXXX X% /
tmpfs XXXXXXXX XXXXXXXX XXXXXXXX X% /dev/shm
tmpfs XXXXXXXX XXXXXXXX XXXXXXXX X% /run
tmpfs XXXXXXXX XXXXXXXX XXXXXXXX X% /run/lock
tmpfs XXXXXXXX XXXXXXXX XXXXXXXX X% /sys/fs/cgroup
/dev/sda1 XXXXXXXX XXXXXXXX XXXXXXXX X% /var/lib/docker/overlay2/...
tmpfs XXXXXXXX XXXXXXXX XXXXXXXX X% /run/user/1000
This output shows the disk usage in 1K-blocks, which can be a bit hard to read. To make it more human-readable, we can use the -h
option. The -h
stands for "human-readable".
Now, type the following command and press Enter:
df -h
The output will be much easier to understand, showing sizes in units like KB, MB, GB, etc.:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 XXG XXG XXG X% /
tmpfs XXXM XXXK XXXM X% /dev/shm
tmpfs XXXM XXXM XXXM X% /run
tmpfs XXXM XXXK XXXM X% /run/lock
tmpfs XXXM XXXK XXXM X% /sys/fs/cgroup
/dev/sda1 XXG XXG XXG X% /var/lib/docker/overlay2/...
tmpfs XXXM XXXK XXXM X% /run/user/1000
The columns in the output are:
Filesystem
: The name of the filesystem.
Size
: The total size of the filesystem.
Used
: The amount of space used on the filesystem.
Avail
: The amount of space available on the filesystem.
Use%
: The percentage of space used.
Mounted on
: The directory where the filesystem is mounted.
The /
entry represents the root filesystem, which is where your operating system and most of your files are stored.
You can also check the disk usage of a specific directory by providing the directory path as an argument to df -h
. For example, to check the disk usage of your home directory (~
), you can use:
df -h ~
This will show you the disk usage of the filesystem where your home directory is located.
Practice using df -h
to check the disk usage of different locations on the system. This command is a fundamental tool for monitoring disk space.
Click Continue to proceed to the next step.