Thursday, April 25, 2013

Finding big size files and directories in Unix and Linux

What is eating my HDD? That is a common question I hear. The response to it is pretty simple. Just search for big files or directories containing a lot of information.

Here are two ways to find big inmediate subdirectories for example from /home/user:
sudo du -h --max-depth 1 / --exclude=proc
ls -d -1 /home/user/*/ | xargs du -hs
Here is how to find files bigger than 20 MB starting at /home/user:
find /home/user -type f -size +20000k -exec ls -lh {} \;
Here is how to recursively find directory sizes starting at /home/user (the bigger will appear last):
find /home/user -type d -print0 | xargs -0 du -s | sort -n

No comments:

Followers