[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A safer "rm" (fileutils)

From: Ingmar Koecher
Subject: A safer "rm" (fileutils)
Date: Thu, 21 Mar 2002 10:16:53 -0500


I don't know how many times a day some system administrator, junior sysadmin, 
part-time unix admin
on this planet deletes the root directory by accident. I have personally heard 
of two cases, one of 
them just yesterday:

A web developer, actually somewhat savvy on the shell, tries to remove some 
directories and makes a
deadly typo:

rm -r /home/username /*

He was following instructions from a memo and thought that there was a space 
after the username. 
I don't have to tell you what our server administrator is doing right now 

If an argument looks like / or /* then prompt the user with a message like this:

address@hidden> rm -r /*
rm: You are about the remove all entries from the root filesystem.
    This will make your system unusable, are you sure? (y/n)

I realize that this could annoy some hard core shell users who don't want to 
see themselves limited,
but in the end it's those gurus that have to fix the problem while they could 
do better things. Well,
to be on the safe side I would introduce an additional switch similar to this:

to restore the original behaviour of the rm command, maybe somebody uses "rm 
-rf /" in a shellscript,
but I really can't imagine who would do such a thing, and why.

I personally see no reason to ever delete the root dir, I don't know what you 
guys think.

I looked at the code (I have some C knowledge) and think that this could be 
somewhat easily inserted
in the rm.c file when the argv[]s are being checked.

I offer to add that change to the rm.c file, but think that you could probably 
do it more elegant
and faster.

This would probably save thousands of hours every year and make Linux more 
friendly to users that are not
yet all the way in understanding every single command.

I would appreciate your feedback and hope that you find my suggestion useful as 

Best regards,

Ingmar Koecher.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]