Linux how to find large directories
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
![](https://static.webit.lv/2022/09/image-2.png)
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
![](https://static.webit.lv/2022/09/image-4.png)
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
![](https://static.webit.lv/2022/09/image-6.png)
In my case /var/www and /var/lib takes up most space