Management Portal

Handy Commands for Viewing & Troubleshooting Disk Space

Handy Commands for Viewing & Troubleshooting Disk Space

Because QuadraNet technicians work with linux servers day-in and day-out, we like to keep little cheat-sheets around in order to quickly view certain information about a system. Whether your server is full on hard disk space, you need to find all files over 100MB in size, or you just want to see what your filesystem looks like in a pretty format, the following cheat-sheet commands for disk space should prove helpful!

To check your Total Disk Usage for the whole server:
df -h

Another useful command is du. Running this command will list all directories with their filesize from your current directory:

To show the total directory size of the current directory, you can run the following command:
du -csh

du command

You can use the following command to search for files over 10MB in size:
find / -mount -noleaf -type f -size +10000k -print0 | xargs -0 ls -lhSr | perl -ne '/(S+s+){4}(S+)s+(S+s+){3}(.*)/ and printf("%*s %sn",7,$2.":",$4);'

And my personal favourite, which will run a recursive du and output a nifty little graphical list of all directories under the one from which you run it:
du -k | sort -n | perl -ne 'if ( /^(d+)s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1ft%st%25s | %sn",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'

du command 2

Max depth is also useful for finding folder/file sizes with limited folder depth:
du -h --max-depth=1