Linux: Show Directory Size: du
Find the Size of a Dir
# show dir size of current dir du --si -s .
--si
- Human readable format in metric unit. For example, M means megabyte (10^6)
-s
- Means sum.
Find Size of All Top-Level Subdirs
# show size of current dir, human readable, 1st level dirs, sort by size. du --si -d1 | sort -h
# show size of current dir, 1st level dirs, sort by size. du -d1 | sort -n
Most Important Options
-s
- “sum”. Do not calculate size directory content.
-d n
-
Calculate all size of subdirs to depth n.
-d 1
would be all the first level subdirs.
Human readable forms. (kilo, mega, giga)
-h
- Human readable form; in binary units.
--si
- Human readable form; in metric units.
Specify your own units:
-k
- Kibi bytes. (kibi = 2^10 = 1024) (default)
-m
- Mibi bytes. (mibi = 2^20 = 1048576)
-B 1000
- Kilo bytes.
-B 1000000
- Mega bytes.
When using “sort”, use -n
to sort by number, use -h
to sort human readable form of number.
Linux, Files and Dirs
- Linux: Navigate Directory
- Linux: List Files
- Linux: Walk Dir: find, xargs
- Linux: View Directory as Tree
- Linux: Copy File
- Linux: Move / Rename, File / Dir
- Linux: Create New File
- Linux: Create New Dir
- Linux: Delete File/Dir
- Linux: Show Directory Size: du
- Linux: Show Difference Between Directories
- Linux: rsync Tutorial