Change website

From Jan 16 2015,


All post content will be move to we's offical website with many content...

Can access website here: http://justox.com

Thanks for your visit!

Friday 27 December 2013

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/*

Example:

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/*
23M
/var/www/atmail
18G
/var/www/backup
2.1M
/var/www/cgi-bin
216K
/var/www/error
2.2M
/var/www/html
972K
/var/www/icons
1.3M
/var/www/manual
368K
/var/www/usage
18G
/var/www/vhosts
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

No comments:

Post a Comment