Dangerous Commands
Deletes or truncates filesPrint a Dry-Run Removal Script
You have cleanup candidates and need a human-reviewable removal plan instead of executing deletion directly from find.
Command
find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf 'rm -i -- %p\n'
Before you run this
System impact: Deletes, truncates, or overwrites data. Requires backup, preview, and exact path review before production use.
When not to use it: Do not pipe generated removal commands into a shell; review, quote, and execute intentionally if cleanup is approved.
Expected output
One printed rm -i command per old cleanup candidate.
System impact
Deletes or truncates files. Nothing changes. The command prints interactive rm commands as text and does not execute them.
May require elevated permissions on protected paths or service-owned files.
When to use it
Use when turning a candidate list into a reviewed cleanup plan for a small, well-understood path.
When not to use it
Do not pipe generated removal commands into a shell; review, quote, and execute intentionally if cleanup is approved.
Recovery / rollback
No undo needed for the dry run. If a printed command is later executed, restore from backup or the source system.
Explanation-only example
Illustrated output, not a live lab run
This example is intentionally illustrative. It shows the command shape without killing real processes or changing your machine.
$ find /work/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %p\n' | sort
2026-06-01 /work/disk-inode-cleanup/var/tmp/uploads/old-export.tar
$ find /work/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf 'rm -i -- %p\n'
rm -i -- /work/disk-inode-cleanup/var/tmp/uploads/old-export.tar
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %p\n' | sortfind /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf 'rm -i -- %p\n'
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
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
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.