From owner-freebsd-questions@FreeBSD.ORG Sun Aug 10 05:11:56 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 233C91065676 for ; Sun, 10 Aug 2008 05:11:56 +0000 (UTC) (envelope-from michael.grant@gmail.com) Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.168]) by mx1.freebsd.org (Postfix) with ESMTP id E36368FC22 for ; Sun, 10 Aug 2008 05:11:55 +0000 (UTC) (envelope-from michael.grant@gmail.com) Received: by wf-out-1314.google.com with SMTP id 24so1271968wfg.7 for ; Sat, 09 Aug 2008 22:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=dneRxZaRs98x6+wkeWDrmLGj2cEJ370gB74Ydv+gC8k=; b=foH58gH2rj0GBI820X1Y6FZC2krBzgJGFA6gH/E5p6WEMWKRHKBFiCZPQ+ZDI06fiH 8JB0xqkPu/WsmRGUjJjVVOL1xPeQO/UjQjnVgIykfkRNC4bnDZrWxS4qVHYTaSJmTe6i Yw7lZSeKvLYvcph6FveD9u4Oqd6mB1NfMoZMA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=A6wMaDHmBKN0j4iZVC/LJwpWioLUkcX97i6d0dX+eVLpeONXNyi3dwWTpI3jSeVbDs 29rZgPH4z3dgFiW4qMERjaelPX/2N+gDvxxbnb9JTENR9CXXdJ2kyBZB42yP122WsVNI PInRXe0Bape6Xo5UUx26Dk0zeP3qtFip7QFFU= Received: by 10.142.178.13 with SMTP id a13mr1601751wff.53.1218345115347; Sat, 09 Aug 2008 22:11:55 -0700 (PDT) Received: by 10.142.246.7 with HTTP; Sat, 9 Aug 2008 22:11:55 -0700 (PDT) Message-ID: <62b856460808092211r50111d3fnd70feeb46f819a43@mail.gmail.com> Date: Sun, 10 Aug 2008 07:11:55 +0200 From: "Michael Grant" Sender: michael.grant@gmail.com To: "Jeffrey Goldberg" In-Reply-To: <34556D79-74F5-4222-A945-DC22628CB17D@goldmark.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <62b856460808091322m38558ec2o1359fff91ae68a79@mail.gmail.com> <34556D79-74F5-4222-A945-DC22628CB17D@goldmark.org> X-Google-Sender-Auth: a96d1830df7bfade Cc: FreeBSD Questions Subject: Re: shutdown/reboot suggestion 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: Sun, 10 Aug 2008 05:11:56 -0000 I have such a script, I put it in /bin/require_hostname and symlinked shutdown, halt, reboot, fastboot, and fasthalt to this script: #!/bin/sh if [ "$1" = `hostname` ]; then shift exec /sbin/`basename $0` $@ else echo "For your protection, use: $0 hostname ..." fi I realize a lot of people have their own tricks and habits for avoiding such stupidity, but what is the problem of fixing the problem globally by getting these commands to take a hostname argument? This could certainly be the basis for another thread (and this is perhaps not the correct list), but is there some way to request a modification across all the unix/linux distributions out there to maintain some level of consistency across them? Except for Posix, is there some overall list which deals with this conformity of all these sibling platforms? Michael Grant On Sun, Aug 10, 2008 at 3:45 AM, Jeffrey Goldberg wrote: > On Aug 9, 2008, at 3:22 PM, Michael Grant wrote: > >> More than once, through carelessness, and I'm sure I'm not alone, I >> have inadvertently shutdown or rebooted the wrong machine. I'm sure >> some of you know that all too familiar feeling when you see >> "Connection closed" instead of your desktop being rebooted. > > I use a combination of tricks. > > 1. I have the hostname in my prompt. > 2. I have a separate color scheme for ssh sessions for each host I commonly > connect to, and a generic color scheme for ssh sessions for other hosts. > These are all distinct from my term window color scheme for my local host. > 3. I rarely run as root, so all of my shutdown's use sudo. My password > isn't the same on all hosts. > > This doesn't work perfectly, but it does help avoid this kind of problem. > > >> I have a suggestion with respect to these commands. What if they >> could be modified to require the hostname of the machine as their >> first argument, otherwise, they refuse to bring the machine down? >> >> shutdown -h now >> >> becomes: >> >> shutdown example.com -h now > > As others have pointed out, you can easily make scripts to do that. > > -j > > > > -- > Jeffrey Goldberg http://www.goldmark.org/jeff/ > >