du command (Linux / bash / sh / zsh)
What it does
Estimate disk usage for files and directory trees. When people search for the du command linux folder size, they usually want du's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Estimate disk usage for files and directory trees.
Syntax
du [OPTION]... [FILE]...
Common options
| Flag / option | Meaning |
|---|---|
| -h | Use human-readable units. |
| -s | Print only a total per argument. |
| -a | Include individual files. |
| --max-depth=N | Limit displayed directory depth. |
Practical examples
Folder total
du -sh downloads/
Shows one readable total.
Largest children
du -h --max-depth=1 /var | sort -h
Sorts immediate /var children by size.
Include files
du -ah project/
Reports files as well as directories.
Common mistakes
- Assuming du and df must match despite deleted-open files and filesystem overhead.
- Scanning remote or pseudo filesystems unintentionally.
Related commands
FAQ
What does du do in Linux?
Estimate disk usage for files and directory trees.
How do I use du from the terminal?
Start with `du [OPTION]... [FILE]...`, then choose only the options needed for the task.
What is a practical du example?
Try `du -sh downloads/` — Shows one readable total.
Can I use du in a shell script?
Yes. du works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.