Hosting Operations
Risk: safeKeep du on One Filesystem
You need a directory-level size view without crossing filesystem boundaries during disk triage.
Command
du -xh --max-depth=1 /lab/disk-inode-cleanup/var 2>/dev/null | sort -h
Before you run this
Risk: safe. 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
Nothing changes. The command measures apparent usage and keeps the scan on one filesystem.
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.
Watch this command run
Example output from a temporary Linux lab
This example uses disposable sample files and sanitized output so you can inspect the shape of the result before touching a real system.
$ df -h /work/disk-inode-cleanup
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 /work/disk-inode-cleanup/var 2>/dev/null | sort -h
8.0K /work/disk-inode-cleanup/var/log
8.0K /work/disk-inode-cleanup/var/tmp
664K /work/disk-inode-cleanup/var/cache
684K /work/disk-inode-cleanup/var
View reproducible demo details
This page shows the sanitized shell transcript and the setup steps needed to reproduce the example.
Lab setup steps
df -h /lab/disk-inode-cleanupdu -xh --max-depth=1 /lab/disk-inode-cleanup/var 2>/dev/null | sort -h
next steps
Related commands
Preview Old Temp Files Before Deleting
The safe version of cleanup is a candidate list first.
find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' | sort
Rank Old Cleanup Candidates by Size
The oldest file is not always the file that buys back meaningful space.
find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
Review Log Files Before Cleanup
Before truncating logs, prove which log files are large and how old they are.
find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr
Find Directories Burning Inodes
Inode cleanup starts by finding the directory with too many files.
find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
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
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.