Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On Linux (RHEL 6) what is the best way to list all the files and sizes that are counting against my quota on a given filesystem?

We have a projects directory and everything I am currently doing is pretty small but my quota is nearly full and I want to see what else is mine so I can clean a bit.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Using find, you should use a way that is safe regarding spaces and other funny symbols that can appear in filenames. This should do (provided your find and du versions accept the options):

find . -type f -user "$USER" -print0 | du -ch --files0-from=-

(the -c option is to have a nice total at the end). This will not count the size of the directories though.

If in the directory tree you have some directories that are not accessible by you, you might get some junk (permission denied) on your screen, so you might want to redirect stderr to /dev/null as:

find . -type f -user "$USER" -print0 2>/dev/null | du -ch --files0-from=-
share|improve this answer
add comment

I would probably just do a find command based on username, I assume that is what they calculate the quota off.

Something like:

#!/bin/bash

for i in `find . -type f -user $(whoami)`; do
    du -h ${i}
done

That will list all files owned by $(whoami) with the file size in human readable format.

Though, that list is really long on my system, so I would probably suggest stdout to a file on that (> output.txt, for example) or adding -maxdepth # in the find command to limit it to a manageable level of directories.

share|improve this answer
    
I was thinking there was some way to do it like this with find. Holy slow batman however. But I bet one can't do much better. –  Brian Larsen Dec 6 '12 at 1:13
    
@BrianLarsen I was trying to think of a way to find a faster one, because you're right this is relatively slow... Also it requires a lot of manual labor to go through your list and clean out the files... If you don't care about the sizes it is way faster without the du -h. Instead you could just run the find . -type f -user NAME > output.txt before leaving for the night and deal with it in the morning. Or include a date in there, and AWK the older files that may not be so important. –  nerdwaller Dec 6 '12 at 2:13
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.