Linux is a versatile operating system that can be used on a variety of devices. One of the benefits of Linux is that it can be used to monitor disk space usage. This article will show you how to view and monitor disk space usage on Linux. To view disk space usage on Linux, open a terminal window and type the following command: df -h This command will display all of the information about the hard drive in use by your computer. The first column will show the size in megabytes, and the second column will show the size in bytes. The third column will show the percentage of free space, and the fourth column will show the percentage of used space. The fifth column will show how much free space is available on your hard drive. The sixth column will show how much free space is available on your swap partition. The seventh column will show how much free space is available on your root partition. The eighth column will show how much free space is available on your home directory. To exit this command, type “exit” at the prompt. To view disk space usage for a specific file or directory, type the following command: df -h /path/to/file/or/directory ..


While it’s usually pretty clear if your system is running out of memory or using too much CPU time, disk usage is another key metric that can sneak up on you over time if you leave your server unattended. You’ll want to regular check your disk usage using these commands.

Checking Disk Usage On Linux

The utility used to quickly check disk usage on almost all Linux systems is df, which stands for “disk filesystems.” It simply prints out a list of all the filesystems on your system.

This command here is invoked with two flags, -h for “human readable,” which prints out byte numbers in KB, MB, and GB, and -T, which displays the type of the filesystem.

df will print out each filesystem alongside the size, how much is used and available, and where it’s mounted to on your system.

You’ll quickly notice that you probably have a lot more “filesystems” than you’d expect. This server only has one solid state drive, but has over 20 filesystems. Most of these are backend stuff used for other programs and services, such as compressed squashfs, virtual tmpfs , and Docker’s overlay systems used for containers.

In this example, ext4 is the real drive, which is obvious because it’s mounted at root, but in multi-drive systems that may not be immediately clear. If you want, you can filter this list by specifying which type you want to see with the lowercase -t flag:

Or by removing what you don’t want to see manually with the -x flag:

You can also ask df for info on any specific filesystem, even including wildcards to match multiple systems by name:

Or, you can ask it for info on a specific mount, which is most useful for quickly getting the info on your root system:

Monitoring At a Glance

Most of the time though, you probably don’t want to remember and type a bunch of commands with specific flags. That’s what the glances utility was made for, and we highly recommend giving it a try.

It’s basically a replacement for built-in utilities like top and htop, except it displays a lot of different performance metrics about your system, the disks. It’s not included in most Linux distros by default, but it’s open source and can be installed from pip, given it’s a Python app.

Then simply run the app to open up the glances dashboard:

You’ll find in the lower left corner some info on disk usage, including current I/O speeds, as well as each physical disk’s total usage. Using this, you can easily spot problems with disks filling up before it breaks your system.

There are plenty of other utilities for monitoring your system, but glances checks all the boxes, so it’s a pretty nice tool to have.

Sending Alerts When Your Disk Usage Is Too High

The main problem with command line tools is that they require you to be proactive about checking for problems. But problems can pop up unexpectedly, so it’s good to get notified about them beforehand.

So, the solution is to set up a daily cron job that will run df automatically to check the usage on the root system. It will compare this with a set value, and if it’s greater, it’ll send a message.

You have plenty of options for how to get messages, and it will depend on your preferred contact. The simplest would be to set up the mail utility to send you emails from the command line. You can read our article on setting up Postfix to handle this for you.

A much cooler method is to send yourself a message directly on a messaging platform you’re active on, such as setting up Slack notifications from your server, which can be easily done using webhooks with curl POST requests.

You can read our article on setting up Slack webhooks for disk space alerts to learn more.

RELATED: How to Setup Slack Notifications for Low Disk Space On Your Server