How to locate large files (> 100 MB) in /home/ for 'cleaning'?

It's Centos 6.x. I tried some commands, but they didn't work.

  • 15
    So which commands did you try?
    – Decado
    Sep 16 '12 at 8:39

Find has it's own -delete option so

find /home -type f -size +100M -delete

should do what you want. Just be careful about where you put the -delete option

Warnings: Don’t forget that the find command line is evaluated as an expression, so putting -delete first will make find try to delete everything below the starting points you specified.

If you want to test this before using it then you need to add -depth as -delete implies it.

find /home -type f -size +100M -depth
  • 7
    For future visitors who may not be on CentOS: Both the modern GNU and BSD variants of find (1) (including that of OS X) support the -delete flag, but it is not part of the standard. If you should need an alternative, use -depth -exec rm {} +.
    – kojiro
    Sep 16 '12 at 23:04
  • Good to know! I was not aware the -delete flag could be used to locate large files... It seems I don't have any... Strange ;) ;) ;)
    – user130370
    Sep 18 '12 at 0:30
  • @EricDANNIELOU: Your point being ?
    – user9517
    Sep 18 '12 at 6:11

ncdu is a nice interactive tool to find big files or directories. It will scan a given directory and show a simple ncurses interface to present sizes of directories. It also has a shortcut to delete a file/directory.

  • 1
    find, du and awk have an advantage of being standard
    – nponeccop
    Sep 16 '12 at 21:21
  • 1
    And ncdu has the advantage of being interactive.
    – liori
    Sep 16 '12 at 21:23
  • I've used ncdu for disk cleanup too! It's just great!
    – B Faley
    Sep 17 '12 at 7:00

Just find: find /home -type f -size +100M

find and remove find /home -type f -size +100M -print0 |xargs -0 rm

du /home | awk '$1 > 1234 { print }'

It searches not for large files but for large folders. In case of running out of file space I try to look both for large files and large folders to identify problematic areas.

  • 1
    du -a will have it print both individual files and folders' totals. Also, on many file systems, you need to add -k to make it print the size in KiB instead of arbitrary block-size counts, so I always include -k as a force of habit.
    – fluffy
    Sep 16 '12 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.