Hosting Operations
Risk: safeFind Directories Burning Inodes
Inode usage is high and you need to locate which directories contain the most regular files.
Command
find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
Before you run this
Risk: safe. Do not assume the largest count is safe to delete; identify the application owner and cache semantics first.
Expected output
A count of regular files grouped by parent directory, sorted highest first.
System impact
Nothing changes. The command counts files by parent directory.
Recovery / rollback: no state is changed.
When to use it
Use when df -ih is high and large-file searches do not explain write failures.
When not to use it
Do not assume the largest count is safe to delete; identify the application owner and cache semantics first.
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 -ih /work/disk-inode-cleanup
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 25G 19G 5G 80% /work
tmpfs 245K 14 245K 1% /run
$ find /work/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
120 /work/disk-inode-cleanup/var/cache/app/shards/a
40 /work/disk-inode-cleanup/var/cache/app/shards/b
View reproducible demo details
This page shows the sanitized shell transcript and the setup steps needed to reproduce the example.
Lab setup steps
df -ih /lab/disk-inode-cleanupfind /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
next steps
Related commands
Summarize Cache File Ages
Cache cleanup is safer when you know whether files are stale or still active.
find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
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
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
List Empty Directories as Cleanup Candidates
Empty directories are low-risk candidates, but they still deserve a preview.
find /lab/disk-inode-cleanup/var/cache/app -xdev -depth -type d -empty -print
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.