Linux how to find large directories

5 days

When you get message “no space left on device” you need to find where all free space gone. To do this I use command du – which stands for disk usage

Bash
du -sh

This command will tell size of directory it is run in

I start investigating from root directory “/”. Add flag -d1 which tells du to count only first level directories

Bash
du -h -d1 /

This command may take some time to calculate directories size. In case of lots of files it may take serveral minutes

You can see which directory is largest one. In my case its /var

Now run same command but in /var directory

Bash
du -h -d1 /var

In my case /var/www and /var/lib takes up most space