How to Determine what is Using the Most Disk Space on a Linux Server?

You may sometimes come across the following error while accessing the cPanel Webmail or WHM – 

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. 

In such a scenario, you should check the VPS disk space and ensure you have not maxed out on the disk space.

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

Check Disk Space Usage via SSH

You can check the disk space usage from SSH by executing the following command – 

df -h

Check Diskspace

You will get an output similar to the one shown in the image above. 

An output indicates that out of 30 GB of total disk space, 2.6 GB of disk space is used, and 26 GB is free. In this case, a 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 their 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 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 Megabytes (MB).
  • df -i // It displays the information of inode numbers and their percentage in the file system. 

Find Files with a Specific Size

The du command can be used with different variations to determine which folder or files are taking up your disk space. 

The following command will display all files and folders sorted by megabytes at the 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 MB 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 – 

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

To run this command on the specific directory, you’ll need to navigate to that directory using the cd command.

Some more Uses of the du command

  • du /home/directory-name // It gives the disk usage summary of the /home/directory-name directory and each sub-directory.
  • du -h /home/directory-name // It gives the results in human-readable format, which means you can see sizes in Bytes, KBs, MBs, and GBs.
  • du -sh /home/directory-name // It gives the grand total disk usage size of a specific directory.
  • du -a /home/directory-name // It gives the disk usage of all the files and directories in the specified directory.
  • du -ah /home/directory-name // It displays disk usage of all files and folders in a specified directory in a human-readable 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

You are not allowed to remove any files from WHM.
To remove the files, you will have to access the individual cPanel accounts’ File Manager that has high disk space usage.


Was this answer helpful?

« Back