DEV Community

chair
chair

Posted on • Edited on

1

Find large files on Linux OS

If you work with Linux VM's, you know it can be a pain to find some deeply hidden large files sucking away at your storage. Fear not, use du.

sudo du -shx /* | sort -h
Enter fullscreen mode Exit fullscreen mode

It will return something like:

...
4K  /opt
72K /root
764K    /run
29M /etc
39M /boot
256M    /home
889M    /usr
33G /var
Enter fullscreen mode Exit fullscreen mode

Looks like our /var folder could use some further inspection, lets adjust our command:

sudo du -shx /var/* | sort -h
Enter fullscreen mode Exit fullscreen mode

Then we see something like:

...
60K /var/spool
224M    /var/cache
6.2G    /var/log
27G /var/lib
Enter fullscreen mode Exit fullscreen mode

It appears we have two more directories worthy of further digging.

We can adjust our command again to inspect /var/lib/* or /var/log/* respectively.

Good luck!

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay