Running out of disk space on a Linux server can slow your applications down. Databases stop writing, logs stop recording, and sometimes, you can’t even log in. That’s why knowing how to check disk space in Linux is a basic but critical skill for anyone managing servers.

In this guide, we’ll show you the exact commands to check disk usage, find what’s consuming space, and free up storage before it impacts your business.

Whether you’re running a SaaS platform, client websites, or internal infrastructure, this guide will help you stay ahead of downtime.

Linux Disk Space Commands at a Glance

Here are the most common commands to check disk space in Linux and what they do:

CommandWhat it showsExample usage
df -hFree and used space on all mounted filesystemsdf -h
df -iInode usage (number of files)df -i
du -sh <dir>Total size of a specific directorydu -sh /var/log
du -h –max-depth=1 <dir>Sizes of top-level subdirectoriesdu -h --max-depth=1 .
ncduInteractive, navigable disk usage viewersudo ncdu /
ls -lhSLargest files in a directory (sorted by size)ls -lhS /var/log

How to Check Disk Space in Linux with df

The simplest way to check disk space in Linux is with the df command. It shows free and used space across all mounted filesystems, making it the quickest way to see if you’re running out of storage.

While you can simply type df, the output shows space in 1-kilobyte blocks, which isn’t very easy to read. We’ll use the -h (human-readable) flag for a much clearer view. To use this tool, open your terminal and run the following command:

df -h

You will see an output similar to this:

Let’s break down what each column means:

  • Filesystem: This is the name of the system for the storage partition. You often see names like /dev/sda1 or /dev/vda1. These refer to the first partition on your primary hard drive. (sda is common for physical drives, while vda is often used for virtual server disks).
  • Size: The total size of the filesystem.
  • Used: The amount of space currently in use.
  • Avail: The amount of free space remaining.
  • Use%: The percentage of the disk that is full. This is the most important column to watch! If this number gets close to 100%, you may start having problems.
  • Mounted on: This is the directory in the file structure where the filesystem is accessible. The most important one is / (the “root” directory), as this is where your entire operating system and all its files are stored.

Useful df Options for Disk Space

The df command has several useful options that make it easier to narrow down problems, check filesystem types, and track inode usage.

How to Check a Specific Filesystem with df

You can specify the path if you only care about the space in a specific directory (like your home folder). For example:

df -h /home

How to Show Filesystem Type in Linux

You can use the -T flag to see the format of your filesystems (e.g., ext4, XFS). For example:

df -hT

How to Check Inode Usage in Linux

Sometimes, you can run out of “inodes” before you run out of disk space. An inode is a data structure that stores information about a file. Think of it like an entry in a library’s card catalog; every file needs one. If you have millions of tiny files, you might exhaust your inodes. To check this, use the -i flag. For Example:

df -i

How to Find What’s Using Disk Space in Linux

Once you know a disk is nearly full, the next step is finding what’s using the space. The du (disk usage) command helps by showing the size of files and directories so you can quickly spot what’s taking up the most room.

A simple du -h lists the size of every subdirectory, but that can be overwhelming. These options make du far more practical:

How to Use du to Check Disk Usage

The du command has several useful options depending on whether you need a quick summary or a detailed breakdown. Here are the most common ways to use it.

How to Get a Summary of Directory Size with du

The -s flag can be used to get a summary of disk usage. This command shows a single numerical value, which is the total size of the directory.

du -sh .

How to List Sizes of Top-Level Directories in Linux

This is perfect for quickly breaking down which folders are the largest without digging too deep. The –max-depth=1 flag tells du to only go one level down. For example, to check the folders in the current directory, you could run:

sudo du -h --max-depth=1

How to Find the Largest Directories in Linux

This is a favorite command of system administrators. It combines three tools to quickly pinpoint the biggest space hogs on your system. For example, if you want to check the ten biggest directories in the webapps directory, then you can run the following command:

du -h ./webapps/ | sort -rh | head -n 10

 Let’s break down how this one-liner works:

  1. du -h <path>: Calculates the disk usage for every file and folder in the provided path.
  2. |: This is the “pipe.” It takes the output of the first command and sends it as the input to the next command.
  3. sort -rh: This sorts the list it receives from du. The -r flag reverses the sort to be descending (largest first), and the -h flag ensures it understands human-readable numbers (so “10G” is correctly sorted as larger than “2M”).
  4. | head -n 10: This final pipe takes the sorted list and shows only the top 10 lines.

Visual and Interactive Ways to Check Disk Space in Linux

Commands like df and du work everywhere, but sometimes a visual tool makes it faster to understand disk usage.

How to Use ncdu for Interactive Disk Usage in Linux

This is a fantastic command-line tool that scans a directory and then provides an interactive, navigable list. You can use your arrow keys to drill down into folders and quickly see what’s using the most space. To install ncdu on Debian and Ubuntu-based systems, run the command sudo apt install ncdu. For CentOS and RHEL systems, you can install it using sudo yum install ncdu. Once the installation is complete, you can scan the current directory by running the command sudo ncdu .

GUI Tools to Check Disk Space in Linux (Baobab, Filelight)

If you are using Linux with a graphical desktop environment, you have even more intuitive options.

  • Disk Usage Analyzer (Baobab): The default tool for GNOME-based desktops like Ubuntu. It provides a visual ring chart that makes it easy to see the largest directories.
  • Filelight: A similar tool for the KDE Plasma desktop environment. This tool displays the disk usage using visual charts, which makes it easy to gather information about your filesystem at a glance.

How to Free Up Disk Space in Linux

Once you’ve confirmed that a disk is nearly full, the next step is cleanup. Start with safe methods like clearing package caches or truncating large logs. Be careful not to delete system files you don’t recognize – that can break your server.

Here are a few safe places to start cleaning to reclaim disk space.

How to Clean the Package Manager Cache in Linux

Package managers (like apt for Ubuntu/Debian or dnf/yum for Fedora/CentOS) download and store installation files in a cache. After installation, these files are often no longer needed. This is usually the safest and easiest way to free up a good amount of space.

For Debian and Ubuntu-based systems:
These two commands will remove old installation files and any unused dependency packages.

sudo apt clean
sudo apt autoremove

For Fedora, CentOS, and RHEL-based systems:
This command will clear out all cached package data.

sudo dnf clean all

Or for older systems using yum:

sudo yum clean all 

How to Manage Large Log Files Safely

By default, the system and application logs are stored in the /var/log directory. Over time, some of these files can grow to several gigabytes in size.

While you could delete a log file with rm, it’s not recommended. A running application may still be “holding” the file open, leading to issues. A safer method is to truncate the file, emptying its contents without deleting it.

To empty a large log file, use the truncate command. For example, to empty a file named large-app.log:

sudo truncate -s 0 /var/log/large-app.log 

This command instantly sets the file’s size to zero, freeing up the space.

How to Review User and Temporary Files

  • /home Directory: Personal files, downloads, and documents are stored here. Use the du commands you learned earlier to navigate your home directory (/home/your-username) and find large files or directories that you no longer need.
  • /tmp Directory: This directory is used for temporary files. While most systems clear it on reboot, sometimes files can be left behind. It’s worth checking this directory for any old, large files that can be removed.

Key Takeaways on Checking Disk Space in Linux

Knowing how to check disk space in Linux with tools like df, du, and ncdu gives you control over one of the most common server issues: a full disk. With these basics, you can spot problems early and act before they cause downtime.

Now that you understand the basics of checking and managing disk space, you can dive deeper into related commands and techniques. We recommend these guides for your next steps:

However, logging in to manually check your disk space isn’t always practical, and by the time you realize there’s a problem, it might already be too late. A modern server control panel is the answer for those who want to move from reactive troubleshooting to proactive management.

This is where RunCloud shines.

RunCloud is designed to simplify every aspect of your server management workflow, including health monitoring. Instead of manually running commands, you get a clean, visual dashboard that displays your disk usage, CPU load, and memory at a glance. More importantly, you can configure alerts to be notified automatically when your disk space reaches a critical threshold, giving you plenty of time to act before it impacts your applications.

If you’re ready to spend less time managing and more time building, take the next step.

Sign up for RunCloud today and discover how effortless server management can be!

Linux Disk Space FAQs

What is the difference between df and du in Linux?

Think of df as your car’s fuel gauge – it shows the total space used and free. du is like the trip computer – it shows which files and folders are using the space.
You use df to determine whether you have a problem and du to locate the problem.

Why does df show full disk, but du shows less usage?

This is a very common point of confusion. If df reports that a disk is 95% full but du only accounts for 85% of the space, there are usually two reasons for this:
Reserved Space: Most Linux filesystems (like ext4) reserve a percentage of the disk (typically 5%) exclusively for the root user. This safety measure prevents essential system services from crashing if a regular user fills up 100% of the disk. df includes this reserved space in its calculation of used space, while du only sums up the actual files it can see.
Deleted Files Held Open by a Process: In Linux, when you delete a file (e.g., a large log file), the space is not freed until the program that was using it closes the file. du will immediately stop seeing the deleted file and won’t count its size. However, df knows the space is still allocated on the disk until the process is restarted or ends. This is why it’s better to truncate active log files instead of deleting them.

What are inodes in Linux?

An inode is a data structure on the filesystem that stores all the information about a file except for its name and actual data. If you run out of inodes, you won’t be able to create new files or directories, even if you still have plenty of physical disk space left. This situation is most common on systems with millions of very small files, so checking inode usage with df -i is an important diagnostic step if you cannot save new files on a disk that appears to have free space.

Is it safe to delete files in /tmp?

Generally, it is safe to delete older files from the /tmp directory, as it is intended for temporary data that applications no longer need. However, you should avoid deleting files that are actively being used, so it’s best to remove files that haven’t been accessed in a while. The safest approach is to let the system handle it, as most Linux distributions are configured to clear the /tmp directory automatically during a reboot.

Author