How to Find What is Using Most of the Disk Space in Linux

Posted at March 4, 2017 at 12:25 am by Jithin

In this tutorial, we can check how to find what is using most of the disk space in Linux Server.

If you notice that you are unable to access your cPanel/WHM, Webmail and your websites are loading slowly, your server may be running out of disk space. Disk space is one of the most important server resource which should be monitored and maintained regularly for good server health. You may see the following error when accessing your cPanel/WHM/Webmail.

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.

This error is usually displayed when your server is maxed out of disk space. You need to check what is consuming the most disk space and remove them if they are not necessary.

This tutorial is for VPS or Dedicated server customers only. If you are receiving this error and you are not on a VPS or Dedicated server, you will need to contact Support for assistance.

 

How to view the overall disk usage

Checking the disk space through shell

You can check the overall disk space consumption through command line. Enter the following command in your terminal/shell.

$ df -h

This command will show you the total disk space of your server, used and free disk space, and the mounted location.

 

Checking the disk space through WHM

Follow the below steps to view the disk space usage for each of your cPanel accounts.

1) Login to WHM.

2) Select “List Accounts” which is under “Account Information”.

3) All your cPanel accounts will be listed and disk space usage can be viewed under “DISK USED” column.

 

How to find files with a certain size

The two useful commands to check which folder files are using disk space are “du” and “find” commands. This commands are used to create a one line script to find the disk usage. Please note that you must have permission to access the files you are searching for before running these scripts. If not, you will get permission errors while running these scripts.

 

Finding all file sizes with the “du” command

The following one line script will display all files and folders sorted by MegaBytes.

du –max-depth=1 | sort -n | awk ‘BEGIN {OFMT = “%.0f”} {print $1/1024,”MB”, $2}’

 

Finding specific file sizes using the “find” command

The following one line script will display specific files in the home directory which are 50000k or larger.

find /home -type f -size +50000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’

 

If you are unable to fix the disk space issue, please contact our Support to fix this for you. You can also upgrade slices for your server anytime to increase server resources.

 

If you need any further help please reach our support department.

 

 

0.00 avg. rating (0% score) - 0 votes

You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply