How to monitor disk usage on Linux

By Angus Published 28 February 2025 Updated 6 March 2026 5 min read

Disk space issues cause performance problems, prevent file uploads and can stop your server responding entirely. Monitoring storage usage helps you identify large directories, detect runaway log files and prevent your server running out of space before it becomes critical.

You will use the du command to check directory sizes and the df command to monitor overall disk usage across your server. These tools show you where storage is being consumed and help you maintain healthy disk space levels.

Before you begin

  • You need SSH access to your server.
  • Basic familiarity with Linux command line navigation is helpful.
  • We recommend running these commands as a regular user rather than root where possible.

Check directory size with du

The du (disk usage) command measures how much space directories and their contents consume. You will start with basic usage and add options to make the output more useful.

  1. Run du on a directory.
    Connect to your server via SSH and run the following command, replacing /path/to/directory with the actual directory path you want to check:
    du /path/to/directory
    This displays the size of the specified directory and all subdirectories in kilobytes.
  2. Make the output readable.
    Add the -h flag to convert kilobytes into megabytes, gigabytes or terabytes automatically:
    du -h /path/to/directory
    The output now shows sizes in a format that is easier to interpret at a glance.
  3. Limit the scan depth.
    For large directory structures, restrict how deep du scans by adding the --max-depth option:
    du -h --max-depth=1 /home/directory
    This shows only the immediate subdirectories within /home/directory without descending further. The number after max-depth controls how many levels down to scan.
  4. Sort directories by size.
    Pipe the output through sort to list directories from largest to smallest:
    du -h --max-depth=1 /home/directory | sort -rh
    The -r flag reverses the sort order and -h tells sort to interpret human-readable sizes correctly. This immediately shows which directories consume the most space.

You can now identify storage-heavy directories quickly. Common culprits include abandoned backups, forgotten uploads and log files that have grown without rotation. Once you locate large directories, check file ownership to determine which user or process is responsible.

Monitor overall disk usage with df

The df (disk free) command shows disk space usage across all mounted filesystems on your server. This gives you a system-wide view of storage consumption rather than focusing on individual directories.

  1. Run df without options.
    Execute the following command:
    df
    This displays all mounted filesystems with their total size, used space, available space and usage percentage. The output appears in 1K blocks by default.
  2. Display sizes in readable format.
    Add the -h flag to convert block sizes into megabytes, gigabytes or terabytes:
    df -h
    The output now matches the format used by du -h, making it easier to compare directory sizes against total disk capacity.
  3. Check a specific partition.
    Target a particular mount point or partition by specifying its path:
    df -h /dev/sda2
    Replace /dev/sda2 with the partition you want to examine. This focuses the output on a single filesystem rather than showing all mounted volumes.

The df command helps you monitor overall capacity and identify partitions approaching their limits. You can now see at a glance which filesystems need attention.

Use additional df options

Two additional df flags provide information beyond basic disk space measurements. These options help diagnose specific storage issues that percentage-based metrics do not reveal.

Check inode usage

Inodes store metadata for files and directories. If your system runs out of inodes, you cannot create new files even when disk space remains available. Run the following command to check inode usage:

df -i

The output shows total inodes, used inodes and available inodes for each filesystem. High inode usage typically indicates a large number of small files, such as cache files or email messages.

Display filesystem types

Different filesystem types have different characteristics and performance profiles. Add the -T flag to see which filesystem format each partition uses:

df -T

The output includes a column showing filesystem types such as ext4, xfs or tmpfs. This information helps when troubleshooting performance issues or planning storage upgrades.

Further reading on server resource management

Disk monitoring forms part of broader server resource management. On shared hosting, exceeding storage limits can affect your account performance. VPS users need to understand how disk usage interacts with other resource constraints. Our guide to LVE resource limits explains how CloudLinux allocates CPU, memory and disk I/O alongside storage quotas.

Regular monitoring prevents storage issues before they impact your sites. The Linux Documentation Project maintains comprehensive guides on filesystem administration that cover advanced topics including quota management and filesystem tuning. These resources help you develop a complete understanding of storage management on Linux systems.

Wrapping up

You can now monitor disk usage on your Linux server using du and df commands. The du command identifies which directories consume the most space, while df shows overall filesystem capacity and usage. These tools help you maintain healthy storage levels and prevent space-related issues.

Run these commands regularly to track storage trends over time. Set up automated monitoring if your server handles critical workloads. Our VPS management guide covers additional server administration tasks including security hardening, performance tuning and backup strategies.

Need more power?

Get scalable resources with our VPS hosting with root access and optional software.

Get VPS Hosting

Starting something new?

Perfect for websites and small businesses unlimited bandwidth with cPanel hosting.

Get cPanel Hosting