Hosting Operations
Read-only, can be slowKeep du on One Filesystem
You need a directory-level size view without crossing filesystem boundaries during disk triage.
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 run broad recursive scans from / during a busy incident unless the extra I/O is acceptable.
Expected output
A human-readable size list for direct children under the selected var directory.
System impact
Read-only, can be slow. Nothing changes. The command measures apparent usage and keeps the scan on one filesystem.
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 after df identifies the pressured mount and you need a scoped directory ranking.
When not to use it
Do not run broad recursive scans from / during a busy incident unless the extra I/O is acceptable.
Recovery / rollback
No undo needed because du only reads metadata and file sizes.
next steps
Related commands
Preview Old Temp Files Before Deleting
The safe version of cleanup is a candidate list first.
find /var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' 2>/dev/null | sort
Rank Old Cleanup Candidates by Size
The oldest file is not always the file that buys back meaningful space.
find /var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' 2>/dev/null | sort -nr | head
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
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
Find Directories Burning Inodes
Inode cleanup starts by finding the directory with too many files.
find /var/cache -xdev -type f -printf '%h\n' 2>/dev/null | sort | uniq -c | sort -nr | head
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.