Linux how to find large directories

20. septembris, 2022

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

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

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

du -h -d1 /var

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