Limited time offer! 25% off our lifetime plans with code LMT25 at checkout. View plans →

Linux Check Disk Space: 8 Essential Commands

Linux Check Disk Space
On this page

To check disk space in Linux, use the df -h command to see how much storage is used and how much is available on each mounted filesystem. If you need to find out which files or directories are consuming that space, use du, find, or an interactive tool such as ncdu.

These commands help Linux administrators monitor storage, troubleshoot full disks, and prevent websites or applications from running out of space. This guide explains eight practical commands, shows when to use each one, and covers what to do when a Linux server runs low on disk space.

Quick Linux Check Disk Space

The simplest way to check disk space in Linux is to run:

df -h

The command displays filesystem capacity, used space, available space, and mount points in readable units such as GB and MB.

For example, the output might look like this:

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        80G   52G   25G  68% /
/dev/vda2       500G  210G  265G  45% /home
tmpfs           3.9G     0  3.9G   0% /dev/shm

These figures are illustrative. Your output will depend on the server’s storage configuration.

ColumnMeaning
FilesystemThe device or filesystem being reported
SizeTotal filesystem capacity
UsedSpace currently reported as used
AvailSpace available to ordinary users
Use%Percentage of space used
Mounted onThe directory where the filesystem is accessible

If the root filesystem mounted at / is almost full, the operating system may struggle to write logs, create temporary files, update packages, or run applications. If /home is a separate filesystem, it can fill up independently.

The df utility reports filesystem usage, while du estimates the space used by files and directories. The official GNU Coreutils disk usage documentation explains both commands.

What Are the 8 Essential Linux Commands to Check Disk Space?

Different commands answer different storage questions. Some show the capacity of a filesystem, while others help locate large files or inspect partitions.

1. Use df -h to Check Filesystem Usage

The df command is the best starting point when you want to check disk space in Linux.

df -h

The -h option means human-readable. It displays sizes using units such as K, M, and G instead of long block counts.

To check the filesystem containing a particular directory, run:

df -h /var

This is useful when investigating a server where logs, application data, or temporary files may be consuming storage. The command reports the filesystem that contains /var, which may or may not be the root filesystem.

You can also include filesystem types:

df -hT

This adds a filesystem type column, helping you identify formats such as ext4 or XFS.

When to use it: Start with df -h whenever a server reports low disk space, a website fails to upload files, or an application cannot write data.

2. Use du -sh to Check Directory Size

The du command estimates how much disk space files and directories occupy. Unlike df, which reports filesystem usage, du helps you investigate where storage is being consumed.

To check the size of a directory, run:

du -sh /var/log

Here is what the options mean:

  • -s displays a summary instead of listing every item inside the directory.
  • -h displays the result in readable units.

For example, the command might return:

2.4G    /var/log

This indicates that the directory’s reported disk usage is approximately 2.4 GB.

You can check other locations in the same way:

du -sh /home
du -sh /var/lib
du -sh /tmp

Replace these paths with directories relevant to your server. Some locations may require elevated permissions to inspect fully.

When to use it: Use du -sh when you already know which directory you want to inspect and need a quick size summary.

3. Use lsblk to View Disks and Partitions

Sometimes, a Linux server appears to have less storage than expected. The problem may be related to the disk layout, partitions, or mount configuration.

The lsblk command displays block devices, including disks and partitions.

lsblk

For additional filesystem information and mount points, use:

lsblk -f

Output:

NAME   FSTYPE SIZE MOUNTPOINTS
vda           100G
├─vda1 ext4    80G /
└─vda2 ext4    20G /home

This is an illustrative layout. Actual device names, partition sizes, and mount points vary.

The output can help you determine whether the system has multiple partitions and where they are mounted. It can also help identify a disk that exists but has not been mounted.

Keep in mind that lsblk shows device and partition information, not the amount of free space inside a filesystem. Use df -h for that.

When to use it: Use lsblk when checking disk layout, investigating newly attached storage, or verifying which partitions are available.

4. Use fdisk -l to Inspect Disk Partitions

The fdisk utility can list partition information for detected disks.

Run:

sudo fdisk -l

Depending on the system, the output includes disk sizes, partition tables, sector information, and partition boundaries.

This can help when you have expanded a virtual disk and need to determine whether the operating system recognizes the new capacity or whether the partition layout needs further investigation.

However, listing partitions does not tell you how much free space is available inside a mounted filesystem.

Important: Listing information with fdisk -l is different from modifying a partition table. Do not create, delete, or resize partitions simply because a filesystem is full. First verify the disk layout, backups, and the correct expansion procedure for your environment.

When to use it: Use fdisk -l when investigating disk and partition structure, particularly after adding or expanding storage.

5. Use du -ah to Find Large Files and Directories

A directory summary is useful, but sometimes you need to see individual files as well.

Run the following command against the directory you want to inspect:

du -ah /var/log | sort -h | tail -n 20

This command combines several utilities:

  • du -ah lists files and directories with readable sizes.
  • sort -h sorts the output by size, understanding size suffixes.
  • tail -n 20 displays the final 20 lines of the sorted list.

The result helps you identify some of the largest entries under the selected directory.

For a whole-server investigation, you might be tempted to run the same command against /. That can take considerable time and produce permission warnings. It may also cross into other mounted filesystems.

Start with one relevant directory and investigate further only if necessary.

When to use it: Use this command when df -h shows that a filesystem is nearly full and you need to find large items inside a particular directory.

6. Use find to Locate Files Larger Than 1 GB

Large backups, database exports, archives, and application files can consume substantial disk space.

To locate regular files larger than 1 GB on the root filesystem, run:

sudo find / -xdev -type f -size +1G -print 2>/dev/null

Here is what each part does:

  • sudo allows access to files that require administrator permissions.
  • find / starts the search from the root directory.
  • -xdev prevents the search from crossing into other filesystems.
  • -type f limits results to regular files.
  • -size +1G selects files larger than 1 GiB according to find‘s size calculation.
  • -print displays matching paths.
  • 2>/dev/null suppresses error messages, including permission errors.

Because error messages are hidden, an empty result does not prove that every directory was inspected successfully. Remove the redirection if you need to review errors.

To locate files larger than 500 MB instead, change the size condition:

sudo find / -xdev -type f -size +500M -print 2>/dev/null

These commands list matching files; they do not delete anything.

When to use it: Use find when you suspect that large files are consuming storage and need their paths before deciding what to do.

7. Use df -i to Check Inode Usage

A Linux filesystem tracks files using inodes. These store metadata such as file ownership, permissions, and timestamps.

A filesystem can run out of available inodes even when it still has free storage capacity. This often happens when a directory contains a very large number of small files.

Check inode usage with:

df -i

The output includes columns such as:

ColumnMeaning
InodesTotal inodes reported for the filesystem
IUsedInodes currently used
IFreeInodes available
IUse%Percentage of inodes used

For example, a filesystem might have plenty of free gigabytes but report 100% inode usage. In that situation, creating additional files may fail.

To investigate, identify the affected mount point and inspect directories that may contain many small files, such as application caches, temporary directories, or mail storage. Avoid deleting files until you understand which application owns them.

When to use it: Use df -i when applications cannot create files even though df -h shows available disk space.

8. Use ncdu to Explore Disk Usage Interactively

If you prefer an interactive view, ncdu can make it easier to explore directory sizes.

First, check whether it is installed:

ncdu --version

If it is unavailable, install it using your distribution’s package manager. For example, on Ubuntu or Debian:

sudo apt update
sudo apt install ncdu

Then scan the directory you want to investigate:

sudo ncdu -x /

The -x option keeps the scan on the same filesystem, which can help prevent results from mixing storage used by other mounted filesystems.

ncdu presents a navigable view of disk usage, allowing you to move through directories and identify large items more easily than reading a long terminal listing.

Be careful with deletion options inside interactive disk tools. Before removing anything, verify its purpose and whether the associated application needs it.

When to use it: Use ncdu when you need to explore a large directory tree and want a more convenient way to locate space-consuming files.

Which Linux Disk Space Command Should You Use?

You do not need to run every command whenever you check storage. Choose the one that answers your immediate question.

TaskCommand
Check overall filesystem usagedf -h
Check a particular filesystemdf -h /var
Check directory sizedu -sh /path
View disks and partitionslsblk -f
Inspect partition informationsudo fdisk -l
Find large files and directoriesdu -ah /path | sort -h | tail -n 20
Locate files larger than 1 GBsudo find / -xdev -type f -size +1G -print
Check inode usagedf -i
Explore disk usage interactivelysudo ncdu -x /

The first command to try is usually df -h. If a filesystem is full, use du, find, or ncdu to investigate the files consuming its capacity.

Why Do df and du Show Different Disk Usage?

It is common for df and du to report different amounts of used space. They measure storage in different ways.

df reports usage at the filesystem level. du estimates space associated with the files and directories it can access.

Several situations can explain the difference:

  • Deleted files still held open: A process may continue using a deleted file until it closes the file handle. df can still count the occupied blocks, while du cannot find the deleted directory entry.
  • Permission restrictions: If you run du without sufficient permissions, it may not count every file.
  • Other mounted filesystems: A scan may include or exclude storage from mounted directories depending on the command and options.
  • Filesystem overhead: Metadata and other filesystem structures consume space that is not represented as ordinary file content.
  • Reserved space: Some filesystems reserve blocks for system use, which can affect the amount available to ordinary users.

If the difference is significant, check the affected mount point and repeat the directory scan with appropriate permissions. On systems with lsof installed, this command can help identify deleted files that processes still hold open:

sudo lsof +L1

Review the results before taking action. Restarting or stopping a process may release the space, but doing so without understanding its role can disrupt a service.

How Do You Fix a Full Linux Disk?

If df -h reports that a filesystem is nearly full, investigate before deleting anything. A full disk can affect websites, databases, logs, mail services, and system updates.

Step 1: Identify the affected filesystem

Run:

df -h

Find the mount point with high usage. A full / filesystem requires a different investigation from a full /home or separate backup partition.

Step 2: Find the directories consuming space

For a quick overview of directories directly under the root filesystem, run:

sudo du -xhd1 / 2>/dev/null | sort -h

This command uses GNU du options. The -x option stays on the same filesystem, -h uses readable units, and -d1 limits the output to one directory level.

If /var is large, inspect it further:

sudo du -xhd1 /var 2>/dev/null | sort -h

Repeat the process with the relevant directory until you identify the source of the usage.

Step 3: Check logs, backups, and caches

Common sources of unexpected disk usage include:

  • Old application or web server logs
  • Database backups and exported archives
  • Temporary files
  • Package manager caches
  • Application uploads and cache directories
  • Container images and unused container data

Do not assume that every large file is unnecessary. Backups may be required for recovery, and logs may be needed for troubleshooting or security investigations.

Step 4: Clean up only what you understand

Use the cleanup method appropriate to the file or service. For example, on Ubuntu or Debian, package cache cleanup can be performed with:

sudo apt clean

This removes downloaded package files from the local APT cache. It does not uninstall installed packages.

For logs, backups, databases, and application data, follow the relevant retention policy or application documentation. Avoid blindly deleting files from /var/lib, database directories, or active service paths.

Step 5: Check disk space again

After cleanup, rerun:

df -h

If the expected space has not been released, check for deleted files held open by running processes and review whether the correct filesystem was cleaned.

If the server regularly runs out of space, consider increasing storage capacity, setting appropriate log retention, moving backups to separate storage, or monitoring disk usage before it reaches a critical level.

How Does Disk Space Monitoring Help CyberPanel Users?

cyberpanel-home

CyberPanel is a free and open-source web hosting control panel. A hosting server may store website files, databases, logs, email, backups, and temporary data. If any of these consume the available storage, websites can encounter upload failures, database errors, or service interruptions.

Linux disk space commands help administrators identify these problems before they cause wider disruption.

For CyberPanel users, a practical routine includes:

  • Checking filesystem usage with df -h.
  • Investigating large directories with du.
  • Monitoring inode usage with df -i.
  • Reviewing backup and log retention.
  • Checking the storage needs of hosted websites and databases.
  • Verifying that sufficient capacity remains for updates and temporary operations.

If storage limits need to be managed for individual hosting accounts, see CyberPanel’s guide to managing quotas in Linux. Filesystem capacity and user quotas are related, but they are not the same: a user may reach an assigned quota even while the overall filesystem still has free space.

CyberPanel does not remove the need to monitor the underlying Linux filesystem. The commands in this guide can help you investigate storage problems at the operating system level.

Frequently Asked Questions

What is the command to check disk space Linux?

Use df -h. It displays the total, used, and available space for mounted filesystems in human-readable units.

How do I check disk space in Linux for a specific directory?

Run df -h /path to see the filesystem containing the directory. To estimate the directory’s own usage, run du -sh /path.

How do I check free disk space in Linux?

Run df -h and look at the Avail column. It shows the space available on each listed filesystem.

Final Thoughts

Checking disk space in Linux starts with df -h, but finding the cause of a full disk often requires additional tools. Use du to inspect directories, find to locate large files, lsblk to understand the disk layout, and df -i to check whether the filesystem has run out of inodes.

For a hosting server, regular monitoring and careful cleanup are safer than waiting for storage to reach 100%. Identify what is consuming space, confirm that it is safe to remove, and make sure the server has enough capacity for its websites, applications, logs, and backups.

Leave a Reply

Your email address will not be published. Required fields are marked *

Chat on WhatsApp