How To Find Directory Size Using Command Line – Linux

Sunday, 1. April 2012

Came across the need to find exact folder/directory size and dis free space on my server and these commands proved very hand

In summary

‘du’ – Is useful command for finding the size of a directory
‘df’ – Is useful command for finding the disk free space / disk usage

To display the total size of the current directory including all the subdirectories.

du -ch | grep total

To display the size of the current directory excluding the size of the subdirectories that exist within that directory

du -S

To display a summary of the directory size

du -s

To display the size of the current directory along with all its subdirectories, but it would exclude all the files having the given pattern present in their file names in this case jpg files

du --exclude=jpg

To display a table consisting of 6 columns. All the columns are very easy to understand. Remember that the ‘Size’, ‘Used’ and ‘Avail’ columns use kilobytes as the unit. The ‘Use%’ column shows the usage as a percentage which is also very useful.

df -h

Leave a Reply

You must be logged in to post a comment.