du
file managementLinux/Unix
The du command is one of the most frequently used commands in Linux/Unix-like operating systems. du Estimate file space usage for files and directories
Quick Reference
Command Name:
du
Category:
file management
Platform:
Linux/Unix
Basic Usage:
du [options] [arguments]
Common Use Cases
Syntax
du [OPTION]... [FILE]...
Options
Option | Description |
---|---|
-0, --null |
End each output line with a null character |
-a, --all |
Write counts for all files, not just directories |
-B, --block-size=SIZE |
Scale sizes by SIZE before printing |
-c, --total |
Produce a grand total |
-d, --max-depth=N |
Print total for directories only N or fewer levels deep |
-h, --human-readable |
Print sizes in human readable format (e.g., 1K, 234M, 2G) |
-k |
Like --block-size=1K |
-m |
Like --block-size=1M |
-s, --summarize |
Display only a total for each argument |
--time |
Show time of last modification of any file in the directory |
--time=WORD |
Show time as WORD: atime, access, use, ctime, or status |
--exclude=PATTERN |
Exclude files that match PATTERN |
-X, --exclude-from=FILE |
Exclude files that match any pattern in FILE |
Examples
How to Use These Examples
The examples below show common ways to use the du
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
du file.txt