From owner-freebsd-questions@freebsd.org Mon Apr 18 04:51:04 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CF68B11571 for ; Mon, 18 Apr 2016 04:51:04 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (wonkity.com [67.158.26.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "wonkity.com", Issuer "wonkity.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id F02ED134E for ; Mon, 18 Apr 2016 04:51:03 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.15.2/8.15.2) with ESMTPS id u3I4p2Pn032703 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 17 Apr 2016 22:51:02 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.15.2/8.15.2/Submit) with ESMTP id u3I4p2vJ032700; Sun, 17 Apr 2016 22:51:02 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Sun, 17 Apr 2016 22:51:02 -0600 (MDT) From: Warren Block To: "Kevin P. Neal" cc: freebsd-questions@freebsd.org Subject: Re: rm -rf -Mitigating the dangers In-Reply-To: <20160418001110.GA82868@neutralgood.org> Message-ID: References: <57140EA2.6020503@holgerdanske.com> <20160418001110.GA82868@neutralgood.org> User-Agent: Alpine 2.20 (BSF 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (wonkity.com [127.0.0.1]); Sun, 17 Apr 2016 22:51:02 -0600 (MDT) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Apr 2016 04:51:04 -0000 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.