Find Linux Box Files or Directories Taking up Space of 1GB or More

This is the easy way to do it;

https://guides.wp-bullet.com/how-to-find-large-folders-taking-up-space-on-linux/

Or this command line solution shows files and directories 1GB and over.

(1) Check root for directories over 1GB;

sudo du -h --threshold=1G --max-depth=1 /

(2) Do the same inside directories you want to check;

sudo du -h --threshold=1G --max-depth=1 .

(3) Once you've found the directory, search for files over 1GB;

sudo find . -size +1G -exec ls -sh {} \;

If you’ve deleted any log files that were in use so they didn’t free up space.

With this command you can see them in human-readable format;

lsof +L1 | numfmt --field=7 --to=iec --invalid=ignore

If rsyslogd is using the files you can just run this;

sudo service rsyslog restart

To truncate log files for example;

> /var/log/mail.log

I’ve used these with Ubuntu 16.04, mainly to find oversized log files.

Leave a Comment