Check Folder Size in Linux | Warp

Introducing Warp Factories: open, flexible infrastructure for building your own cloud software factory. Learn More

The short answer

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 du command (which stands for "disk usage") as follows:

Bash

$ du -sh <path>

Where:

For example:

Bash

$ du -sh ~/server
632M   /home/johndoe/server

Outputting the size of subdirectories

To also output the size of subdirectories, you can specify the depth using the -d flag as follows:

Bash

$ du -h -d <depth> <path>

Where:

For example:

Bash

$ du -h -d 1 ~/server
237M   /home/johndoe/server/node_modules
325M   /home/johndoe/server/.next
 32M    /home/johndoe/server/public
 35M    /home/johndoe/server/.git
2.0M    /home/johndoe/server/src
632M   /home/johndoe/server

Easily retrieve these commands using Warp's AI Command Suggestions feature

If you’re using Warp as your terminal, you can easily retrieve this command using the Warp AI Command Suggestions feature:

Entering check folder size in the AI Command Suggestions will prompt a du command that can then quickly be inserted into your shell by doing CMD+ENTER.