Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Minor nitpicking: "command line" instead of Linux. On Windows it does not move files to the recycle bin either, but Linux graphical file managers do.
-
For your projects, you could use a version manager system (such as git, mercury or SVN), they use a hidden folder that does not get deleted with rm and often they use write protected files, which means rm will ask before removing.
And don't use the -f flag if you can avoid it. -
Pro-tip: Us this instead of rm:
dd if=/dev/urandom of=/dev/sda bs=1M
replace /dev/sda with the drive of the correct partition. You can be sure, the files you want to delete will be deleted after the command finished. -
you are just gonna automate typing fluffycat and after a couple of occasions it won't make a difference
-
tbjgolden723yI did it from home dir once, stopped it halfway through but I'm still scarred to this day
-
I have made this mistake multiple times before and now I just refuse to use a wildcard if I'm deleting stuff. If it's one folder I'll type it out. If it's a lot of folders I'll use find first, glance over the output, then find -exec rm -rf {} \;
-
Force flag and wildcard are high reason to think what you are about to execute as part of surgery.
-
cho-uc18843yThanks for all your suggestions.
I still think that is not secure enough though.
The problem is that I press up arrow key often (too lazy to type the command). My finger can slip accidentally, instead of the correct command that I want, I choose the rm command.
I just want Linux to give me a prompt/warning before executing it. -
cho-uc18843y@EmberQuill
Owh that's nice I didn't know that.
But it will prompt for every file deleted. ☹
Not very helpful if I have lots of files and dir to delete. -
You are not alone, even the UNIX-HATERS Handbook from '94 already lists the problem of unforgiving commands 😉
https://web.mit.edu/~simsong/www/...
Anyway, I can only recommend to stay away from adding molly guards (like aliasing rm to rm -i) for regular actions - it will only lead to entering commands more easily, until you do it on a system without such guard.
The system @EmberQuill suggested seems to be the better, or using a path instead of a wildcard as @darkwind said. -
Meanwhile I'm over here Shift+Deleting, once in a blue moon things like this rant remind me that the recycle bin is even a thing (I disable the desktop icon to make things squeaky clean),
Related Rants
In several occasions I run rm -rf * in the wrong folder (or wrong server!!).
No big deal so far, but I had to spent more time to redo my work since Linux has no fucking recycle bin like Win!
So I created this helper function to give my brain a few seconds to think before my finger hit Enter.
delete_all_files()
{
echo "WARNING:Delete all files? Type fluffycat to proceed"
read x
if [ "$x" = "fluffycat" ]
then
echo "Deleting all files..."
rm -rf *
fi
}
alias myrm=delete_all_files
Hehehe... I am a genius 😎
random
rm -rf *