How to Get Size of Folder (and all its contents) in Linux / Unix via PuTTy / Terminal

If you ever wanted to know “how big is that directory?” and by this you mean the entire directory, and you have access over SSH, via PuTTy or your command line terminal of choice, to your Linux  server or VPS, then there is a little command which will tell you, in useful units, exactly what the contents of a directory add up to… in total.

Directory is what we call folders in Linux. Folder is – broadly – a Microsoft Windows term (I think – leave a comment moaning a lot if I’m wrong). Its in common usage because “folder” with the little icon is a nice visual way of showing what a directory actually is. But the two terms are interchangable. They mean the same thing: a section of the file system which holds files (or sub-directories).

Get Size of Folder (and all its contents) via Terminal

du -msh FolderName

Where FolderName = the name of the folder you would like to assess the size of!

This is a good alternative to using just

du -h FolderName

Which will output a list of folder content(s), with the relative size(s). So, depending on the circumstances, you may find either of the above helpful implementations of the du command.

du is the command for “disk usage” which basically means “how much disk does this use???”.

For more on this, see here.

Got questions or comments?

Please leave them below.

A little about Silicon Dales

We’re developers who like Open Source, and use it to help medium to large sized businesses do well in the online space. We resell Google Workspace, develop and optimize WordPress and WooCommerce, and are AWS Consulting Partners. We also have partnerships with many other household names, but those four are the main events – the things we use pretty much all the time, day-in, day-out. If this sounds like something your company could benefit from some serious expertise with, then don’t hesitate to contact us.

Leave a comment

No links of any kind allowed in comments - if you add any links, your comment will automatically be deleted.