Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Use an alias' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use an alias
Authored by: Mike Klein on Oct 14, '02 11:33:15AM

In .bashrc, .tcshrc or .cshrc, add a line such as:

alias rm="rm -i"

Then whenever the rm command is entered, rm -i will be executed.

Safer and easier.



[ Reply to This | # ]
Use an alias
Authored by: osxpounder on Oct 14, '02 01:32:57PM

I guess that one nice thing about using the ./-i file is that it can travel with the folder .... so that, if another user tries to "rm *", and she doesn't have an alias set up to protect her, the ./-i file will provide that last-ditch warning before she deletes files ..... no?

I notice this only protects a user if a glob construct[*] is used. If I have a file named 'blah' in the same folder as a file named "-i", I can still delete without protection by typing "rm blah" ... so that's a good reason to put the "rm -i" alias in my own .*rc file ....

Thanks for a potentially very useful tip!

[*] note: now that I think about it, I'm not sure if the asterisk is a glob construct or not. I may misunderstand the term.



[ Reply to This | # ]
Use an alias
Authored by: crackpip on Oct 14, '02 08:56:35PM

In general it isn't recommended to alias rm -i as rm. The reason for this is that you can get used to relying on it and if you move to another machine or some other situation where your resource file isn't loaded, then you can make a big mistake. Instead its recommended to use an alias like,

alias rmi `rm -i`



[ Reply to This | # ]
Use an alias
Authored by: charles488 on Oct 16, '02 08:26:25PM

Another safer option is to use the alias del 'rm -i' instead of alias rm 'rm -i'. You might also want to add the aliases copy 'cp -i' and move 'mv -i' while
your at it which will provide the same type of warning for the cp and mv commands.



[ Reply to This | # ]
VERY bad idea
Authored by: deleted_user17 on Oct 15, '02 04:51:23AM

One day you will sit on a OS X box without this alias and enter "rm -rf /" - 2 min. later the whole installation is gone...

Never, never, never use this alias!



[ Reply to This | # ]
VERY bad idea
Authored by: gnuadam on Oct 15, '02 09:56:35AM

Uh, even if you alias rm -i with rm, if you type rm -fr /*, you'll still toast your machine. The "-f" flag (which forces the delete to occur without any prompting) seems to override the "-i" flag (which asks the user to confirm deletion). I typed rm -ifr <file>, and it deleted without prompting.



[ Reply to This | # ]
Use an alias
Authored by: Glanz on Oct 15, '02 08:43:49AM

Excellent point! This is the method I have been using for years with the BSDs. It especially helps when people are "talkinatcha" while you are typing! :)
This is one of the best tips for an ADMIN I have seen on these boards.



[ Reply to This | # ]