Linux Survival Basics
Read-only, can be slowFind Which Folder Is Filling the Disk
A server is low on disk and you need a folder-level view before drilling into individual files.
Command
du -sh /var/* 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: Avoid assuming the largest folder is safe to delete; size is not ownership or importance. Scope the path more tightly on busy systems.
Expected output
A sorted list of directory sizes under `/var`, often pointing you toward logs, caches, backups, or application data.
System impact
Read-only, can be slow. Nothing changes on disk. The command prints human-readable folder sizes and sorts them.
May require elevated permissions on protected paths or service-owned files.
Scope this to the smallest useful path or service on busy systems.
When to use it
Use this before deeper `find` searches or cleanup decisions. It is a broad map, not the cleanup step.
When not to use it
Avoid assuming the largest folder is safe to delete; size is not ownership or importance. Scope the path more tightly on busy systems.
Recovery / rollback
No filesystem state is changed. If the scan is too slow, stop it with Ctrl-C and rerun against a narrower path.
next steps
Related commands
Find the Files Eating Your Disk
The disk was full, but guessing at folders was the slow part.
find /var -type f -printf '%s %p\n' | sort -nr | head -20
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 /var 2>/dev/null | sort -h
Check Inodes When Disk Space Looks Fine
Sometimes the disk has free bytes but still cannot create files.
df -ih
Review Log Files Before Cleanup
Before truncating logs, prove which log files are large and how old they are.
find /var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' 2>/dev/null | sort -nr | head -50
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.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.