How to Check the Size of Folders in Linux
[#output-folder-size] The short answer [#output-folder-size]
On Unix-like operating systems such as Linux and macOS, to output the size of a folder in a human-readable format, you can use the [.inline-code]du[.inline-code] command (which stands for "disk usage") as follows:
Where:
- The [.inline-code]-s[.inline-code] flag is used to specify a directory depth of [.inline-code]0[.inline-code] (i.e. equivalent to [.inline-code]-d 0[.inline-code]).
- The [.inline-code]-h[.inline-code] flag is used to display the size in a human-readable format using automatic unit suffixes, such as [.inline-code]K[.inline-code] for Kilobytes, [.inline-code]M[.inline-code] for Megabytes, and so on.
- The [.inline-code]path[.inline-code] argument is the relative or absolute path to the folder.
For example:
[#output-subfolder-size] Outputting the size of subdirectories [#output-subfolder-size]
To also output the size of subdirectories, you can specify the depth using the [.inline-code]-d[.inline-code] flag as follows:
Where:
- The [.inline-code]depth[.inline-code] argument is the number of subdirectories the [.inline-code]du[.inline-code] command will traverse down.
For example:
[#easily-recall-commands-with-ai] Easily retrieve these commands using Warp's AI Command Suggestions feature [#easily-recall-commands-with-ai]
If you’re using Warp as your terminal, you can easily retrieve this command using the Warp AI Command Suggestions feature:
![](https://cdn.prod.website-files.com/64b7506ad75bbfcf43a51e90/668ecb30e361a8b8b72f8827_AD_4nXeJ8TUrUOsxX3ZNrC9QUkRF7YLkgTC7JWOj7v6Tb-LuS7mUX-aut6reDhfJ72vwM-CiCmKQqVRXGpDdP2oJfKovHfElrM1QPmifGEuc-VFnVzIkpCOLG84jJpQcPuGFuFtp2L1YGf3HR5VWNGCw_QhoeyPG.gif)
Entering [.inline-code]check folder size[.inline-code] in the AI Command Suggestions will prompt a [.inline-code]du[.inline-code] command that can then quickly be inserted into your shell by doing [.inline-code]CMD+ENTER[.inline-code].