How to Check Disk Usage in Linux
How to Check Disk Usage in Linux
Running out of disk space is one of the most common issues Linux administrators encounter. A full filesystem can prevent applications from writing logs, interrupt backups, cause databases to fail, or even stop services from starting correctly. In many cases, the problem develops gradually and goes unnoticed until the server begins reporting errors.
Before deleting files or expanding storage, it's important to understand how your disk space is being used. Linux provides several built-in tools that make this easy. With just a few commands, you can check overall filesystem usage, inspect directory sizes, identify storage bottlenecks, and determine whether further investigation is needed.
Commands such as df, du, and lsblk are among the essential Linux commands every administrator should know.
When Should You Check Disk Usage?
Checking disk usage isn't something you should only do after receiving a "No space left on device" error. Monitoring available storage regularly helps identify potential issues before they affect applications or users.
Some common situations where checking disk usage is recommended include:
● A server suddenly becomes slow.
● Applications fail to write logs or upload files.
● Scheduled backups stop completing successfully.
● Monitoring tools report high storage utilization.
● You suspect a directory is growing unexpectedly.
It's also a good habit to verify available space before installing software updates, restoring backups, or importing large databases. These operations can temporarily require significantly more storage than expected.
Check Disk Usage with the df Command
The easiest way to check disk usage in Linux is with the df command. It displays information about mounted filesystems, including their total capacity, used space, available space, and utilization percentage.
Run:
df
A typical output looks similar to this:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 41152860 15846320 23212844 41% / tmpfs 4021764 0 4021764 0% /dev/shm /dev/sdb1 104755200 62458924 36946276 63% /data
Although this output contains all the necessary information, the values are displayed in 1 KB blocks, which makes them difficult to interpret at a glance.
Adding the -h option converts the output into human-readable units such as KB, MB, GB, or TB:
df -h
Example output:
Filesystem Size Used Avail Use% Mounted on /dev/sda2 40G 16G 23G 41% / tmpfs 3.9G 0 3.9G 0% /dev/shm /dev/sdb1 100G 60G 36G 63% /data
Here's what each column means:
| Column | Description |
|---|---|
| Filesystem | The storage device or partition. |
| Size | Total capacity of the filesystem. |
| Used | Disk space currently in use. |
| Avail | Free space available for new data. |
| Use% | Percentage of the filesystem that is occupied. |
| Mounted on | The directory where the filesystem is mounted. |
For most administrators, the Use% column is the first place to look. A filesystem consistently above 85–90% deserves attention, even if it hasn't reached full capacity yet.
Keep in mind that df reports usage at the filesystem level. It tells you how much space is being used, but not which directories or files are responsible. That investigation comes later using the du command.
Real-world tip: The df command displays mounted filesystems rather than physical storage devices. If you need to identify the disks and partitions available on your server, see our guide on how to list disks in Linux before continuing with storage analysis.
View Disk Usage for a Specific Filesystem
On systems with multiple disks or partitions, you may only be interested in a particular mount point rather than every mounted filesystem.
Instead of reviewing the entire list, specify the path you want to examine.
To view usage for the root filesystem, run:
df -h /
Example output:
Filesystem Size Used Avail Use% Mounted on /dev/sda2 40G 16G 23G 41% /
To inspect a separate data partition:
df -h /data
or check the /home filesystem if it resides on its own partition:
df -h /home
On production servers, separate filesystems often serve different purposes.
Checking a specific mount point makes it easier to focus on the area experiencing high utilization. A typical server might use its mount points as follows:
● / contains the operating system.
● /home stores user data.
● /var contains logs, package caches, and application data.
● /data may hold databases or website content.
Checking a single filesystem lets you focus on the area that's actually running out of space.
It's also worth remembering that one full partition doesn't necessarily mean the entire server is out of space. A server may have plenty of free capacity on one filesystem while another reaches 100% usage and causes applications to fail.
df vs du: What's the Difference?
New Linux users often confuse the df and du commands because both relate to disk usage. However, they answer different questions.
The commands complement each other: df reports filesystem capacity, while du attributes usage to files and directories.
| Command | Shows | Best Used For |
|---|---|---|
| df | Filesystem usage | Checking available disk space on mounted filesystems |
| du | Directory and file sizes | Finding where disk space is being used |
Suppose your root filesystem is almost full.
Running:
df -h
Might show:
Filesystem Size Used Avail Use% /dev/sda2 40G 38G 1.2G 97%/
The output confirms that the filesystem is nearly full, but it does not identify the directories responsible.
The du command provides the missing directory-level detail. It allows you to inspect directories individually and determine which ones consume the most storage.
A typical troubleshooting workflow looks like this:
● 1. Check filesystem usage with df.
● 2. Identify the filesystem that is running out of space.
● 3. Examine directories on that filesystem with du.
● 4. If necessary, investigate individual large files.
Using both commands together provides a much clearer picture than relying on either one alone.
Measure Directory Sizes with the du Command
While df reports usage for entire filesystems, the du command measures how much disk space individual directories and files consume.
For that reason, du is one of the most useful tools for locating directories and files that consume storage.
To display the size of the current directory, run:
du -sh
Example output:
2.4G
The options used here are:
● -s — display only the total size instead of every subdirectory.
● -h — present values in a human-readable format.
To examine all directories inside the current location, use:
du -h
Depending on the number of files, this command may produce a large amount of output because it reports the size of every directory recursively.
To measure a specific directory without scanning the current location, pass its path directly:
du -sh /var/log
Example:
1.8G /var/log
Checking a known path directly saves time when logs, backups, or uploaded files are already the likely source of the problem.
Unlike df, which reports filesystem capacity, du helps pinpoint the directories responsible for disk usage. In practice, administrators often start with df to determine which filesystem is nearly full and then switch to du to identify the directories consuming the most space.
Real-world tip: On production servers, /var/log, /var/lib, /home, and /tmp are common starting points when storage usage increases unexpectedly. They may contain growing logs, databases, caches, user files, or temporary data.
Find the Largest Directories
Once you've identified a filesystem with high utilization, the next step is determining which directories consume the most storage.
One of the easiest ways to do this is by limiting the depth of the du output.
For example, to display the size of each top-level directory under the root filesystem, run:
du -h --max-depth=1 /
Example output:
4.8G /var 7.1G /home 1.2G /usr 120M /boot 13G /
Limiting the output to one directory level provides a useful overview without producing thousands of lines.
If you're already inside a directory and want to compare its immediate subdirectories, use:
du -sh *
Example output:
850M backups 3.1G logs 220M uploads
Comparing immediate subdirectories is particularly useful in application, website, and backup directories.
A directory-level summary may reveal where most of the storage is concentrated, but it does not show which individual files are responsible.
To continue the investigation, see our guide on how to find large files in Linux.
Real-world tip: If a directory suddenly starts consuming significantly more space than expected, avoid deleting files immediately. First determine what changed. Rapidly growing log files, failed backup jobs, or application caches often indicate an underlying problem rather than being the root cause themselves.
View Inode Usage with df -i
Disk capacity isn't the only resource that can become exhausted.
Linux filesystems also use inodes, which store metadata about files and directories. Every file consumes one inode, regardless of its size.
This means a filesystem can still have several gigabytes of free space while refusing to create new files because no inodes remain.
To check inode usage, run:
df -i
Example output:
Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda2 2621440 2618000 3440 99% /
The output is similar to the standard df command but reports inode usage instead of storage capacity.
Pay particular attention to the IUse% column.
If it approaches 100%, applications may begin reporting errors even though the filesystem still has available disk space.
Inode exhaustion is most common on systems that store very large numbers of small files, including:
● mail servers;
● cache directories;
● image hosting platforms;
● CI/CD build systems;
● application sessions.
Real-world tip: It's not unusual to see several gigabytes of free disk space while applications still report "No space left on device." In many cases, the filesystem has simply run out of available inodes rather than storage capacity.
Use ncdu for Interactive Disk Usage Analysis
While df and du are available on virtually every Linux system, many administrators prefer using ncdu for interactive disk usage analysis.
Unlike standard command-line output, ncdu displays directories in a navigable interface that allows you to quickly identify the largest storage consumers.
On Debian and Ubuntu, install it with:
sudo apt install ncdu
On RHEL, Rocky Linux, AlmaLinux, and Fedora:
sudo dnf install ncdu
Run ncdu without a path to analyze the current directory:
ncdu
Or analyze the entire root filesystem:
sudo ncdu /
The interface sorts directories by size and lets you navigate using the keyboard, making it much faster to investigate storage issues than repeatedly running du commands.
Although ncdu is not installed by default on most distributions, its interactive interface can significantly reduce the time required to locate storage-heavy directories.
Common Disk Usage Mistakes
The commands themselves are simple, but interpreting their output incorrectly can send the investigation in the wrong direction.
Confusing df with du
These commands answer different questions.
df reports filesystem usage, while du measures the size of directories and files. Using one when you actually need the other often leads to confusion.
Assuming the Entire Server Is Full
A single filesystem may reach 100% usage while other partitions still have plenty of available space.
Always verify which filesystem is affected before investigating directories.
Ignoring Mounted Filesystems
Directories such as /mnt, /media, or dedicated data partitions may be mounted on separate storage devices.
Checking only the root filesystem can cause you to overlook the partition that's actually running out of space.
Forgetting About Inodes
If applications report "No space left on device" but df -h still shows available storage, don't forget to check inode usage with:
df -i
It's a quick check that can save a significant amount of troubleshooting time.
Conclusion
Checking disk usage is one of the first steps in diagnosing storage-related problems on a Linux system.
In most cases, a simple workflow is enough:
● 1. Start with df to check overall filesystem usage.
● 2. Identify the filesystem approaching full capacity.
● 3. Use du to determine which directories consume the most space.
● 4. Verify inode usage if disk space appears available but applications still report storage errors.
● 5. Switch to ncdu when you need a faster, interactive view of disk usage.
Together, df, du, df -i, and ncdu show whether the problem affects filesystem capacity, a specific directory, or the available inode count. Confirming the source of the problem before removing data reduces the risk of deleting files that active services still require.