rm -rf -Mitigating the dangers

Warren Block wblock at wonkity.com
Mon Apr 18 04:51:04 UTC 2016

On Sun, 17 Apr 2016, Kevin P. Neal wrote:

> On Sun, Apr 17, 2016 at 03:30:58PM -0700, David Christensen wrote:
>> On 04/17/2016 10:10 AM, Odhiambo Washington wrote:
>>> I am wondering if I should place a feature request on this or just do it my
>>> way:)
>>> With great power comes great responsibility and as such I think there
>>> should be a wrapper around rm to warn sysadmins that what they are about to
>>> do with -rf is dangerous, yes?
>>> Read input from sysadmin 3 times, looking strictly for their confirmation
>>> before effecting the `rm -rf`.
>>> Could it be that what I am smoking/drinking is the issue here or I have
>>> your support? LOL
>> I have this in my .bashrc:
>>      alias rm='rm -i --one-file-system'
>> So, an accidental 'rm -rf' should limit destruction to one file system.
> And, for those occasions where your job is on the line, it is important
> to know that "pwd" and "/bin/pwd" do _not_ work the same. If you really
> want to know where you are before you do a "rm -rf *" then you must use
> the "/bin/pwd" command.

I suggest to never give rm -rf an unqualified "*".  Using a path with
rm -rf doesn't make it safe, but it does make it safer.  It's a good 
protective habit to develop.

More information about the freebsd-questions mailing list