How to Check Disk Usage of Individual Directories Using SSH

On this page
  1. Prerequisites
  2. Command
  3. Command Explanation
  4. Example
  5. Understanding the Results
  6. Checking Website Usage
  7. Checking a Specific Subdirectory
  8. Summary

If you want to identify which directories are using the most disk space on your hosting account, you can do so using a simple SSH command.

Prerequisites

Before proceeding, make sure that SSH access is enabled for your account.

Once SSH access is active, connect to your account using your preferred SSH client.

Command

To display the size of directories located inside a selected directory, use:

du -h -d1 ~/selected-directory/ | sort -h

Command Explanation

  • du – Displays disk usage information.
  • -h – Formats the output in a human-readable format (KB, MB, GB).
  • -d1 – Limits the output to one directory level.
  • sort -h – Sorts the results by size.

Example

To check the usage of your home directory, run:

du -h -d1 ~ | sort -h

Example output:

1.1M    /home/user/Maildir
1.5M    /home/user/.razor
4.2M    /home/user/.spamassassin
13M     /home/user/.cagefs
15M     /home/user/.cache
13G     /home/user/imap
59G     /home/user/domains
82G     /home/user

Understanding the Results

In the example above:

  • Maildir uses approximately 1.1 MB.
  • .cache uses approximately 15 MB.
  • imap uses approximately 13 GB.
  • domains uses approximately 59 GB.

The final line shows the total size of the analyzed directory:

82G     /home/user

This makes it easy to identify directories consuming the most disk space.

Checking Website Usage

To analyze a specific website directory, use a command similar to:

du -h -d1 ~/domains/example.com/ | sort -h

This is particularly useful when:

  • Investigating high disk usage.
  • Locating large backup files.
  • Identifying oversized caches.
  • Finding old logs or temporary files.
  • Troubleshooting quota-related issues.

Checking a Specific Subdirectory

You can also analyze a particular directory, for example:

du -h -d1 ~/domains/example.com/public_html/wp-content/ | sort -h

This can help determine whether plugins, themes, uploads, or cache files are consuming excessive space.

Summary

To quickly identify which directories are using the most storage space, connect via SSH and run:

du -h -d1 ~/selected-directory/ | sort -h

The command displays directory sizes in a readable format and sorts them from smallest to largest, making it easy to locate files and folders responsible for high disk usage.

Didn't find an answer?

Our support team is here for you 24/7 – write to us and we will help you sort it out.