Challenge
DifficultyEasy
Learner activity6 solved of 7 attempts

Check How Much Disk Space Is Left on a Linux Server

Ivan Velichko
by  Ivan Velichko · on
Linux
Before you copy a large file or start a backup, you need to know whether the disk has room for it. Practice reading the size and the available space of a filesystem with the df command.

You have access to a Linux server with a single disk. The disk holds one filesystem, and it is mounted as the root directory (/). A part of the space is already taken by the operating system and the application data.

Your mission is to:

  1. Find the total size of the root filesystem
  2. Check how much space is still available on it
  3. Calculate how much space is missing for a new backup

Enter the sizes in gibibytes (GiB), for example 25G or 7.4G.

A nightly job is about to write a backup archive of several GiB to the backups directory. The archive is too large to fit there. Find out how much space you need to free up before the job runs.

Hint: Checking Filesystem Usage

The df (disk free) command reports the total size, the used space, and the available space of every mounted filesystem. By default, it prints the numbers in 1K blocks, which are hard to read. Look for a flag that makes the sizes "human-readable" in df --help.

Hint: Reading the df Output

The df output has one row per mounted filesystem. Most of the rows on this server are tmpfs filesystems that live in memory and don't use the disk. The row you need has / in the Mounted on column.

Hint: Size Units

With the -h flag, df uses powers of 1024, so G stands for a gibibyte (GiB). The uppercase -H flag switches to powers of 1000 and prints larger numbers for the same filesystem.

Hint: Used and Available Space

The used and the available space don't add up to the total size. An ext4 filesystem keeps a few percent of its blocks for the root user, so the system stays operable when regular users fill the disk. The Avail column shows the space that a regular user can still write.

Hint: Finding the Filesystem of a Directory

A directory always belongs to some mounted filesystem, and the space available in the directory is the space available on that filesystem. Pass a path to df, and it prints only the filesystem that holds this path.

Problem
Solution
Start
Black Friday 2026