7

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.

2 Answers2

5

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=-
1

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.

nerdwaller
  • 18,014