How to delete unwanted files in Raspberry Pi command?
Here’s a safe, no-nonsense cheat-sheet for deleting files from the Raspberry Pi command line (Raspberry Pi OS / Linux).
0) Quick safety checklist
- 
Double-check the path:
pwdthenls -al(shows hidden files too). - 
Tab-complete names; quote paths with spaces:
"My file.txt". - 
Prefer interactive/confirming deletes at first:
rm -i/rm -I. - 
Avoid
sudo rm -rfunless you’re 100% sure. 
1) Delete single files
2) Delete many by pattern (glob)
3) Delete directories
4) Delete by size, age, or name (find)
These are powerful—and safer—because you can preview first.
Tip: swap
-delete/-exec … rmwith
5) Free up space (common places)
6) “Send to Trash” from terminal (reversible)
If you prefer a recycle-bin style workflow:
7) Permissions & stubborn files
8) Nice extras for finding big stuff
Common gotchas to avoid
- 
Don’t run destructive commands as root in
/,/boot,/usr,/etc,/lib,/varunless you know exactly what you’re doing. - 
rm -rf .*in your home directory can nuke..(parent) on some shells—don’t do that. - 
Always preview with
find … -printorlsbefore deleting. 

评论
发表评论