Web Server Rescue
Read-only, can be slowFind Large Directories with du
You know a filesystem is full and need to identify which top-level directory is consuming the most space without crossing into other mounts.
Command
du -xh --max-depth=1 /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: Do not start at `/` on a busy production system unless you have a reason. Keep the path narrow and stay on one filesystem.
Expected output
A size-sorted list of directories under `/var`, with the largest entries at the bottom because `sort -h` orders smallest to largest.
System impact
Read-only, can be slow. Nothing changes, but the scan can create disk I/O. The command measures directory 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.
Recovery / rollback: no state is changed.
When to use it
Use after `df -h` identifies the full mount and you need a folder-level map before inspecting individual files.
When not to use it
Do not start at `/` on a busy production system unless you have a reason. Keep the path narrow and stay on one filesystem.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 25G 19G 5G 80% /work
tmpfs 982M 12M 970M 2% /run
$ du -xh --max-depth=1 /var 2>/dev/null | sort -h
24M /var/tmp
180M /var/cache
1.4G /var/log
3.8G /var/lib
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
df -hdu -xh --max-depth=1 /var 2>/dev/null | sort -h
next steps
Related commands
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
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 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
Find Which Folder Is Eating Disk Space
When your Mac is full, start with the biggest folders in the current directory.
du -sh ./* 2>/dev/null | sort -h
Show TLS Certificate Names
The cert was valid, but not for this hostname.
openssl s_client -connect edge.test:443 -servername edge.test </dev/null 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName
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.