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.
Table of Contents
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:
Maildiruses approximately 1.1 MB..cacheuses approximately 15 MB.imapuses approximately 13 GB.domainsuses 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.