X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; q=dns; s=default; b=j3 5rSrIrQUs9pkDbLWarHFqBeWQL6isIpwYa189DRuol3ShxUxcYO+Q59zMW8iGoGg C75tvUMIjC5PEd/f1SAdDUW2yAxtLci4D/8+v9GPoDGe4tSdPNu41P3WqnJ2C89X FURbjagztY6ydxR2kq6Ny1qZ9HICtw24BNLVA36z8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; s=default; bh=NM8W9261 qBzdxhlb7bCzLVcHmto=; b=C2zTzUj7QGYu80Ol9nXpWRUWYlv8R5tek1xLHxjP XwtQ65YA9WD5J9kzDbfwOKzLaGtBmIc3RxJFPUx3aTo/yNr9sgIsgs6MN0tjVTMY W3G9wGxcBheP4LUPoFW6c9/WYQZ2N84nS3v682bkifZE1u+sPiddtdboTuRf5htd meg= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.3 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pb0-f50.google.com MIME-Version: 1.0 X-Received: by 10.68.202.38 with SMTP id kf6mr2272114pbc.43.1382613726932; Thu, 24 Oct 2013 04:22:06 -0700 (PDT) In-Reply-To: <21085.47545.572257.639431@consult.pretender> References: <21085 DOT 47545 DOT 572257 DOT 639431 AT consult DOT pretender> Date: Thu, 24 Oct 2013 12:22:06 +0100 Message-ID: Subject: Re: Root/Administrator privileges from cygwin terminal From: Anthony Geoghegan To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes > The only solution I have now is to open a new bash window as administrator. > So is there a way to elevate (or change) privileges from with a bash shell? A while ago, I researched a Cygwin equivalent for sudo but that's what I ended up doing, myself. > 2. Is there any better way to determine that one has Administrator > privileges than to run something like: > id -G | grep -Eq '<\544\>' > Or: > [[ `id -G` =~$(echo "\<544\>") ]] > > (note the 'echo' is used to get around incompatibilities in > various versions of bash on how word separators are recognize.) I use something similar: [[ $(groups) == *Administrators* ]] It's more readable and it works on pretty much every version of Bash. For POSIX compatibility, you could probably use something like: case $(groups) in *Administrators*) echo Member of Administrators group;; *) echo Not a member of Administrators group;; esac This approach has worked well enough for me in the past but I don't do anything too unusual other than stopping / starting Windows services. Regards, Anthony Geoghegan -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple