Cheatsheet: du

Basic operations

show all sizes of all files and folders in 'block size' units (512 or 1024 bytes)

du
648	./node_modules/@mui/system/esm
16	./node_modules/@mui/system/legacy/Box
16	./node_modules/@mui/system/legacy/ThemeProvider

human readable size

du -h
324K	./node_modules/@mui/system/esm
8.0K	./node_modules/@mui/system/legacy/Box
8.0K	./node_modules/@mui/system/legacy/ThemeProvider

size of a directory (human readable)

du -s -h public
25M	public

size of all directories/files within folder

du -s -h public/*
144K	public/framework-f1641c8a1b7c00529b04.js
184K	public/framework-f1641c8a1b7c00529b04.js.map
104K	public/graphviz

Combining with sort

sort files by size

du -s public/* | sort -n
8	public/_redirects
8	public/component---src-pages-404-js-0de2b2490830b3060bdc.js

sort by size (largest first)

du -s public/* | sort -n -r
3696	public/d6a7430b-a74824202bfa5cd46396.js.map
3656	public/component---src-pages-markdown-editor-js-6c0072a17ef59f7695f9.js.map

sort by size human readable

du -s -h public/* | sort -h -r
1.8M	public/d6a7430b-a74824202bfa5cd46396.js.map
1.8M	public/component---src-pages-markdown-editor-js-6c0072a17ef59f7695f9.js.map

sort by size limit to top 1

du -s -h public/* | sort -h -r | head -n 1
1.8M	public/d6a7430b-a74824202bfa5cd46396.js.map