Archive

Posts Tagged ‘directory size’

Linux – Find Linux Directory Space Usage

November 17, 2010 Leave a comment

Sometimes it is necessary to find the size of a given directory on a unix/linux environment, this helps to see where the most amount of space is being consumed and where directories can be trimmed to free up space.

$ du

– This command tells you a list of sub-directories and their current sizes for the directory you are currently in. The last line of this command tells you the size of the current directory including all sub-directories. By default the sizes are in Kb

$ du /home/oracle

– This command gives you the size of the specified directory.

$ du -h

– This gives you an output of directory sizes in human readable format. The directory sizes are suffixed with a K for Kb, M for Mb, and G for Gb.

$du -ah

– This provides the sizes of all directories and files for the current directory and its subdirectories in human readable format.

$du - c

– This provides a list of sub-directories and a grand total of the directory and its sub-directories.

$du -ch | grep total

– This provides only the grand total amount for the directory and its sub-directories. Only one line is displayed.

$du -s

– Another way of finding the total size of the directory and its sub-directories is to issue this command. You can append the command to make it human readable also.

$du -S

– This provides a list of the sizes of all files in the current directory only. The total at the end is the sum total of the files in the current directory excluding the sub-directory.

$du --exclude=oracle

– This provides a list of the sizes for the current directory and its sub-directories, but excludes all files with the given pattern in their filenames.

Categories: Commands, Linux Tags: , ,