fixing rm * (was: Worm/Passwords)

Juergen Wagner gandalf at csli.STANFORD.EDU
Tue Nov 22 07:35:25 AEST 1988


In article <717 at quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:
>In article <1812 at ndsuvax.UUCP> ncgus at ndsuvax.UUCP (jim gustafson) writes:
>>Maybe I missed something, but doesn't everybody have 'rm' re-defined as
>>an alias or $HOME/bin/rm?
>
>I do hope not.  It is a bad idea to define aliases for the standard
>commands (and if you are a system administrator, giving new users 
>profiles with such redefinitions in them is _extremely_ bad manners).

Redefining "rm" as "rm -i", "mv" as "mv -i", and "cd" et al. to the prompt-
changing versions is *VERY* common practice, I think. System administrators
do not put these into the .cshrc to surprise people, they are there to help
beginners to start in a safe environment (at least safer than without these
definitions), without having to worry about mistakenly typing "rm foo/ *".
Expert users may change that as soon as they are logged in for the first time.
(Before I work on a system, I check the .cshrc, .login, etc. to see what's
in there.)

>For example, I very much like the "-F" option in ls, but it would be
>incredibly stupid to "alias ls 'ls -F'".  Instead I "alias lf 'ls -AF'"
>and use "lf".  Just so, if you don't like what rm does, _leave_it_alone_
>and define yourself an alias, script, C program, or whatever, called
>"del", "delete", "delf", or whatever takes your fancy, and use that.

Bad example. "ls" is a command you can execute umpteen plus one times without
destroying anything. "rm" and "mv" *CAN* destroy files. I agree that aliasing
"ls" to "ls -F" or similar stuff would be stupid. Aliasing "rm" is less stupid
because it protects the user against him/herself. Personally, I tend to give
longer names to destructive command than to the non-destructive versions.
"rm" prompts me for confirmation, "delete" doesn't. If an expert user doesn't
like that aliasing as soon as he/she logs in for the first time...

>Apart from the obvious problem of changing something so that it no longer
>does what the manual says it does,

The point is, if UNIX gives a novice user a command to erase important files
with five keystrokes and no confirmation, this command should be made safe,
so it will at least prompt for confirmation. By the kind of aliasing we are
discussing here, the safety of commands is increased, never decreased. 
Therefore, the manual accurately describes what "rm" does, modulo that little
safety feature.

People who know little about UNIX are likely to know basic commands such as
"rm", "mv", "cp", "ls", ... and they know what they do. They do not know how
to alias commands, edit the .cshrc. Everything is magic in the beginning, so
they try to stick to the commands they think they know. Well, and then it just
happens that files are accidentially deleted.

>				    there are other reasons for not relying
>on aliases for standard commands.  For example, we have several different
>systems on our net here, running several varieties of UNIX.  Some of them
>have the C shell, some don't.  Some of them I have my own accounts on,
>some of them I share a "porting" account.  If I rely on an alias for rm
>to protect me, the next time I log into a new box I will be _sunk_.

I guess, you wouldn't consider yourself a novice user of UNIX. If you like the
unaliased "rm", that's fine. Unexperienced users do appreciate the extra
protection.

As for non-csh shells, how about "rm () { /bin/rm -i $* }" as an 'alias' for
"rm".

As a consultant, I am also working under other peoples accounts. If I am just
fixing something, I simply do not rely on "rm" being aliased. If I have to work
longer under some account, I define the aliases necessary, or just load my
setup into a new shell.

To summarize: Some people like the aliases, some don't. Those who like and
appreciate them (like novice users and many expert users) should have them,
those who don't like them, who are considering them harmful, bad style, or
whatever, shouldn't have them. I don't seen any reason why anybody should 
insist on any solution being better than the other - it depends!

However, it is desirable to protect new users against the unwanted effects of
some silent and destructive commands, so I would put the respective aliases
into new users .*rc file. Those who don't like them (etc.) can remove the
aliases easily, and will have completely different .cshrc/.login files than
the system default, anyway.

This is my personal opinion.
-- 
Juergen Wagner		   			gandalf at csli.stanford.edu
						 wagner at arisia.xerox.com



More information about the Comp.unix.wizards mailing list