From owner-freebsd-questions@FreeBSD.ORG Tue May 8 10:28:59 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1A0F316A401 for ; Tue, 8 May 2007 10:28:59 +0000 (UTC) (envelope-from trip@nosubject.org) Received: from smtp2.34sp.com (smtp2.34sp.com [80.82.113.68]) by mx1.freebsd.org (Postfix) with ESMTP id D344213C458 for ; Tue, 8 May 2007 10:28:58 +0000 (UTC) (envelope-from trip@nosubject.org) Received: from localhost (localhost.34sp.com [127.0.0.1]) by smtp2.34sp.com (Postfix) with ESMTP id 5A46E2440A; Tue, 8 May 2007 11:28:57 +0100 (BST) X-Virus-Scanned: by Clam Anti Virus Received: from smtp2.34sp.com ([127.0.0.1]) by localhost (smtp.34sp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VJTHqzJCwbIs; Tue, 8 May 2007 11:28:57 +0100 (BST) Received: from [192.168.1.6] (chello062178049105.17.11.vie.surfer.at [62.178.49.105]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp2.34sp.com (Postfix) with ESMTP id DBF9324402; Tue, 8 May 2007 11:28:56 +0100 (BST) Message-ID: <464050E3.4010904@nosubject.org> Date: Tue, 08 May 2007 12:28:51 +0200 From: Bernd Trippel User-Agent: Thunderbird 1.5.0.10 (X11/20070403) MIME-Version: 1.0 To: freebsd-questions@freebsd.org, ray@stilltech.net, carpetsmoker@rwxrwxrwx.net References: <200705051705.43504.ray@stilltech.net> <20070506005530.GA5251@glitch.rwxrwxrwx.net> <463D2B0C.2030603@u.washington.edu> <20070506032313.GA6098@glitch.rwxrwxrwx.net> In-Reply-To: <20070506032313.GA6098@glitch.rwxrwxrwx.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Subject: Re: disaster recovery - did I do the right thing? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2007 10:28:59 -0000 Martin Tournoij typed on 06/05/07 05:23: > On Sat 05 May 2007 18:05, Garrett Cooper wrote: >> Martin Tournoij wrote: >>> On Sat 05 May 2007 17:05, Ray wrote: >>>> Hello all, >>>> I did something stupid the other day (sleep deprivation combined with a "clever" hack were the main reasons), and I'm just curious if I did >>>> the right thing afterwards. >>>> >>>> The mistake: >>>> /usr/local/# rm -f * >>>> note that root was running bash as a shell at the time, found in /usr/local/bin or something. >>>> >>>> What I did was to start over, reinstall from scratch. >>>> my question, was there an easier way? >>>> thanks, >>>> Ray >>> You can use pkg_info -ga to check for missing files in your packages. >> For (t)csh: >> alias rm "rm -i" >> >> For (ba)sh: >> alias rm="rm -i" >> >> Now that you've learned :). >> >> Martin's suggestion is good though -- would have done that considering that all that lived in /usr/local were ports. >> >> -Garrett > > The problem with this is that it will ask confirmation for every file it > deleted. > Which is gets pretty annoying after a while, also, if you delete a > directory containing a 100 files, you will have to press 'y' a 100 > times. > This will probably lead to the habit of using 'rm -f', and/or simply > pressing y all the time without actually looking at the confirmation > message. > In any case, it's not likely to prevent any such accidents. > For the sake of it: You could use rm -I: quoting the rm man page: -I Request confirmation once if more than three files are being removed or if a directory is being recursively removed. This is a far less intrusive option than -i yet provides almost the same level of protection against mistakes. Output looks like this: # rm -fI * remove 10 files? Would even be better if it would list e.g. 2 or 3 files. > A better solution would be to write a script that would move files > instead of deleting them. > You should name this script to something else than rm, when you're > working with a new or "foreign" system, you will expect rm to move > files, instead of deleting them ... and we can all see another > disaster coming there... true, sometimes fingers have a memory of their own ;) > > Another hint would be the 'rmstar' option in tcsh, when set, tcsh will > ask confirmation before executing 'rm *'. > > Note that aliasing 'cp' and 'mv' to 'cp -i' and 'mv -i' is an > *extremely* wise idea, in the past I have often accidentally overwritten > files that should not have been overwritten, leading to various > problems. >