Analyzing disk space usage on a linux server

du -chs command

To locate which directories may be using an excessive amount of disk space, you can find them by executing the du -chs command as shown.  This will show how much disk space is used by each subdirectory.

Note: Make sure you execute this command as root!

Plesk example

# du -chs /var/*

cPanel example

# du -chs /home/*


Assume the output of the du command is as shown:
# du -chs /var/*
89M /var/cache
8.0K /var/db
86M /var/lib
93M /var/log
36.2G /var/www

You would quickly notice that /var/www/ is consuming a very large amount of disk space.  We can round this down even further by ‘walking’ the command into the www folder by typing:

# du -chs /var/www/*
36.2G total

Now you will notice that the 'load' is split by both the /var/www/backup and /var/www/vhosts directories.

Continue this procedure until you have found where your space is being used.

find command

You can use the find command if you know the minimum size files you are looking for.

To search for a file that is at least 100MB, you can use:

find / -size +100M

To search for a file that is at least 1.1GB in size, try:

find / -size +1.1G

This article has been provided by Codero Hosting, the leading provider of reliable
dedicated, managed and cloud hosting services. Need more information on this
topic or to learn more about Codero’s hosting services please
www.codero.comchat with us online or give us a call at 866-2-CODERO. 
Posted in
Last update:
2015-12-03 20:39
Average rating:0 (0 Votes)