How to determine what is using the most disk space on a Linux server?

There are times when you receive following error while accessing the cPanel WebMail or WHM. You should have a look with VPS disk space and make sure that you have not maxed out on the disk space. 

Sorry for the inconvenience!
The filesystem mounted at / on this server is running out of disk space.

cPanel operations have been temporarily suspended to prevent something bad from happening.
Please ask your system admin to remove any files not in use on that partition.

If you have root access to your Linux VPS, you can check disk space usage either via SSH or WHM.

Check disk space usage via SSH

You can easily check disk space usage from SSH by issuing the following command.

df -h

Check Diskspace

You will get output similar to above. An output indicates that out of 25 GB of total disk space 6.9 GB Diskspace is used and 17 GB is FREE. In this particular case, significant amount of free disk space is available so you do not need to remove any data to release the disk space. We have come across several incidents where customers used 99% of disk space and locked themselves out from all access. Here are some useful variants of the df command.


df -a  //  It displays the file system disk usage and their memory utilization.

df -k  //  It displays the file system information and usage in 1024-byte blocks.

df -m //  It displays the information of file system usage in MBs (MegaBytes).

df -i   //  It displays the information of inode numbers and their percentage in file system. 

Find files with a certain size

To determine which folder or files are taking up your disk space, command du can be used with different variations. The following command will display all files and folders sorted by MegaBytes at current location.

du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}' 

You should see an output of all files and folders with their size in MegaBytes as follows.

Check Files in MBs

Similarly, you can use variations of this command to list all files and folders over 1 GB as follows. To run this command on the specific directory, first, you’ll need to navigate to that directory using the cd command.

du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"GB", $2}'  

Here are some more uses of du command.

du  /home/directory-name  // It gives the disk usage summary of directory /home/directory-name and each of its sub directories.

du -h /home/directory-name  //  It gives the results in Human Readable Format that means you can see sizes in Bytes, KBs, MBs and GBs.

du -sh /home/directory-name  //  It gives grand total disk usage size of specific directory.

du -a /home/directory-name  // It gives the disk usage of all the files and directories in specified directory.

du -ah /home/directory-name  // It displays disk usage of all files and folders in specified directory in human readeable format.

du -ha --time /home/directory-name  // It displays the disk usage of all files and folders sorted by the modification time.

Check disk space usage from WHM

If you are not comfortable with shell commands, you can always use WHM. From WHM, you can monitor the cPanel accounts with the highest disk space usage. See our article on how to check disk space usage of cPanel accounts via WHM. Note that you are not allowed to remove any files from WHM. To remove the files, you will have to access individual cPanel account’s File Manager that has the large disk space usage.


Related Articles

How to run ClamAV scan from SSH in cPanel server?

In this article, we'll discuss how to run ClamAV scan via SSH in cPanel/WHM server. ClamAV is one...

How to Install Tomcat 7 on Centos?

Tomcat is an open-source web server that is built in Java Servlet and JavaServer Pages...

How to upgrade Debian 7 (Wheezy) to 10 (Buster) version?

It is always recommended to upgrade the version to prevent any security vulnerability. You can...

How to find all files/folders with 777 permission in Linux?

First of all, let us understand the meaning of 777 file permission in Linux. Suppose, any of the...

How to run ClamAV and Maldet together on cPanel server?

You may be familiar with ClamAV and Maldet scanner (aka Linux Malware Detect). They're widely...

  • 0 Users Found This Useful

Was this answer helpful?