Apple Terminal
Read-only, can be slowFind Which Folder Is Eating Disk Space
Disk space is low and the user needs to identify which project folder or cache is largest.
Command
du -sh ./* 2>/dev/null | sort -h
Before you run this
System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.
When not to use it: Do not run from the filesystem root expecting instant results. Start narrow.
Expected output
A human-readable sorted list such as 4.0K ./notes and 1.2G ./video-export.
System impact
Read-only, can be slow. Nothing changes. The command calculates and sorts apparent disk usage.
Scope this to the smallest useful path or service on busy systems.
Recovery / rollback: no state is changed.
When to use it
Use in Projects, Downloads, Desktop, or cache directories to find big items quickly.
When not to use it
Do not run from the filesystem root expecting instant results. Start narrow.
Explanation-only example
Illustrated output, not a live lab run
This example is intentionally illustrative. It shows the command shape without killing real processes or changing your machine.
$ printf '%s\n' '4.0K ./notes' '850M ./node_modules' '1.2G ./video-export'
4.0K ./notes
850M ./node_modules
1.2G ./video-export
$ printf '%s\n' '4.0K ./notes' '850M ./node_modules' '1.2G ./video-export' | sort -h
4.0K ./notes
850M ./node_modules
1.2G ./video-export
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
printf '%s\n' '4.0K ./notes' '850M ./node_modules' '1.2G ./video-export'printf '%s\n' '4.0K ./notes' '850M ./node_modules' '1.2G ./video-export' | sort -h
next steps
Related commands
Find Which Folder Is Filling the Disk
The disk was full. The fastest clue was the folder, not the file.
du -sh /var/* 2>/dev/null | sort -h
Inspect Release Disk Usage
Disk pressure during deploys often starts in old release directories.
du -sh releases/* 2>/dev/null | sort -h | tail -10
Find Large Directories with du
Once you know a filesystem is full, the next question is where.
du -xh --max-depth=1 /var 2>/dev/null | sort -h
Keep du on One Filesystem
A cleanup scan should not wander into mounted backups or network storage.
du -xh --max-depth=1 /lab/disk-inode-cleanup/var 2>/dev/null | sort -h
Find What Is Using a Local Dev Port
Your dev server says port 3000 is busy. Ask macOS who is holding it.
lsof -nP -iTCP:3000 -sTCP:LISTEN
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.