How to Check the Size of Folders in Linux
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:
$ du -sh <path>Where:
- The -s flag is used to specify a directory depth of 0 (i.e. equivalent to -d 0).
- The -h flag is used to display the size in a human-readable format using automatic unit suffixes, such as K for Kilobytes, M for Megabytes, and so on.
- The path argument is the relative or absolute path to the folder.
For example:
$ du -sh ~/server
632M /home/johndoe/serverOutputting the size of subdirectories
To also output the size of subdirectories, you can specify the depth using the -d flag as follows:
$ du -h -d <depth> <path>Where:
- The depth argument is the number of subdirectories the du command will traverse down.
For example:
$ 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/serverEasily 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.
Related articles
Bash Comments
Comments will help make your scripts more readable
Reading User Input
Via command line arguments and prompting users for input
Curl Post Request
Use cURL to send data to a server
Upload Files With curl
Learn how to upload a file to FTP, SFTP servers, Artifactory, and AWS S3 using the curl command.
How To Copy A Directory In Linux
Learn how to copy directories and their content in Linux using the cp command with options like -r for recursive copying, -i for interactive mode, and -a for preserving attributes.
Create Groups In Linux
Learn how to manually and automatically create and list groups in Linux.
Count Files in Linux
Learn how to count files and folders contained in directories and subdirectories in Linux using the ls, find, and wc commands.
List Open Ports in Linux
Learn how to output the list of open TCP and UDP ports in Linux, as well as their IP addresses and ports using the netstat command.
Format Command Output In Linux
Learn how to filter and format the content of files and the output of commands in Linux using the awk command.
Create Directories Recursively With mkdir
Learn how to recursively create nested directories using the mkdir command, Bash scripts, and Python scripts.
Remover Users in Linux
Learn how to remove local and remote user accounts and associated groups and files in Linux using the userdel and deluser commands.
Switch Users In Linux
Learn how to switch between users, log in as another user, and execute commands as another user in Linux.