`alias rm="rm -i"` considered harmful?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Droplet of life
--
Chapters
00:00 `Alias Rm=&Quot;Rm -I&Quot;` Considered Harmful?
00:29 Accepted Answer Score 38
01:05 Answer 2 Score 4
01:32 Answer 3 Score 4
02:04 Answer 4 Score 2
02:33 Answer 5 Score 1
03:40 Thank you
--
Full question
https://superuser.com/questions/384769/a...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#bash #rm
#avk47
ACCEPTED ANSWER
Score 38
You're right.
It's bad because you get used to it. If you're on a system that doesn't have it, and you rm
, it immediately starts deleting and you're wondering what's going on.
Many users are used to SSH'ing into different systems; so using lots of different systems, sometimes without personalized user accounts (including aliases) set up, is rather common.
Instead, use e.g. alias rmi='rm -i'
and learn to use that one. If that isn't set up on a different system, you didn't accidentally delete files and can always fall back to typing the full command.
ANSWER 2
Score 4
Like @Daniel said, it's not harmful in and of itself, other than training you to expect it to be there. In fact, it's the default set-up on CentOS (and by extension RHEL, I presume - been too long since I've used one) machines, and it's a massive pain in the tuchus. For the rest of my time at that gig, I typed /bin/rm in order to avoid the "Linux for people who shouldn't have root access" setup.
ANSWER 3
Score 4
I think the big danger is that people might rely on something like this to filter a glob. Imagine you want to delete some images from a directory, but not all of them:
rm -i pics/*.jpg
You could use that to filter the glob manually, which would be completely reasonable. But, if you had aliased it and were using rm
and happened to land in a shell without that alias and try it... you just deleted all your pictures, oops!
Personally I also find this alias to be harmful to my blood pressure ;). But that's just me.
ANSWER 4
Score 2
In addition to what Daniel Beck said, I found myself using -f
to bypass the -i
, which is potentially dangerous as it results in using rm -f
and rm -rf
unnecessarily. Somehow related: a way to prevent rm -rf
issues is this is to create file called "-i" as duscissed in answer of this question:How do I prevent accidental rm -rf /*?.
But again, if that alias wasn't there, I wouldn't use -f, and the whole thing won't be an issue.