Quick Overview

Quickly check the used vs free space on your server.

df -h

Sample Result

Filesystem            Size  Used Avail Use% Mounted on
                       37G   19G   16G  56% /
tmpfs                 939M     0  939M   0% /dev/shm
/dev/sda1             485M   52M  408M  12% /boot

Find Largest Files/Folders

Quickly hunt down your biggest space suckers by using this to find your 10 largest files and folders (change 10 to the number of your choice).

du -hxa /var/* | sort -rh | head -10

Sample Result

18G	/var/www/html/my-massive-file.zip
18G	/var/www/html
18G	/var/www
52M	/var/lib
47M	/var/cache/yum/x86_64/6
47M	/var/cache/yum/x86_64
47M	/var/cache/yum
47M	/var/cache
33M	/var/www/vhosts
28M	/var/cache/yum/x86_64/6/updates/33acdae266801d5d1abf38eaf424bc06104b2dbfcb325a4fe33d47c8a3f42a16-primary.sqlite

Tip: try changing -hxa to -hxs to “summarize” the results instead of displaying “all”). Also, the “h” makes the sizes human readable (otherwise they are all in bytes).

Search Only Top Level Directories

You can view only the sizes of the top level directories by using the depth flag -d

du -hxa -d0 /var/* | sort -rh | head -10

List Delete Files Still on Disk

sudo lsof | grep deleted | less
0 0 votes
Article Rating
in CentOS, LAMP, Linux
Notify of
Inline Feedbacks
View all comments