Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
15  
So which commands did you try? –  Decado Sep 16 '12 at 8:39
add comment

4 Answers

up vote 31 down vote accepted

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
share|improve this answer
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 ;) ;) ;) –  Eric DANNIELOU Sep 18 '12 at 0:30
    
@EricDANNIELOU: Your point being ? –  Iain Sep 18 '12 at 6:11
add comment

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

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

share|improve this answer
add comment

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.

share|improve this answer
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! –  Meysam Sep 17 '12 at 7:00
add comment
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.

share|improve this answer
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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