Ralph Shumaker wrote:
> Gabriel Sechan wrote:
> 
>>
>>
>>
>>> From: Ralph Shumaker <[EMAIL PROTECTED]>
>>> Stewart Stremler wrote:
>>>
>>>> begin  quoting Lan Barnes as of Fri, Apr 06, 2007 at 04:19:02PM -0700:
>>>> [snip]
>>>>
>>>>
>>>>> I was taught that command in my first or second Unix class, long
>>>>> before I
>>>>> was allowed near a keyboard.The instructor said write this down and
>>>>> memorize it so you never do it by accident.
>>>>>
>>>>>
>>>>
>>>> When you type "rm -rf", you should sit back, and put your hands in your
>>>> lap for a second.  Think of it as a zen moment.
>>>>
>>>>
>>>
>>> Why would anyone actually *want* to use that command?  (Serious
>>> question.)
>>>
>> The -r?  I frequently want to delete an entire directory.  The -f? 
>> Because sometimes files are marked read only.  Examples on a daily
>> basis-  tarballs and SCM systems frequently leave read only files on
>> your hard drive.
> 
> 
> Granted, but given the potential for destruction from that command, one
> would think that the command invoked with those switches would caution
> the human when invoked on "/" or even a first level directory before
> poceeding.
> 
> At least one would think that --preserve-root would be on by default. 
> Further, one would think that this switch would also protect first level
> directories at least.
> 
> Oh well, I guess it would be best to take SS's practice of mounting
> certain volumes read only.  That would have prevented the largest part
> of the problem in the story in the link.  If /etc and all the essential
> binaries were in a volume mounted read only, they could have saved
> themselves a lot of headaches.  Had the Vax assembly programmer *not*
> been there, ... , or the emacs had *not* been open, ... , or any of the
> other happy coinky-dinks, a read only system of the base OS (and device
> drivers) would have been a godsend.

Another practical recommendation:

 Never include _any_ paths in a rm -rf command

That is, if you want to get rid of a tree at /path/to/somedir
 Always cd to the direct parent .. cd /path/to
 Run the command with the bare dir name .. rm -rf somedir

The idea: if you _never have any slash_ in the command then you can't
accidentally get a disaster such as could happen with inadvertent
spaces, such as

  rm -rf / path/to/somedir  .. would operate on '/'  OOPS

Regards,
..jim


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to