This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Root/Administrator privileges from cygwin terminal
- From: Anthony Geoghegan <anthony dot geoghegan at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 24 Oct 2013 12:22:06 +0100
- Subject: Re: Root/Administrator privileges from cygwin terminal
- Authentication-results: sourceware.org; auth=none
- References: <21085 dot 47545 dot 572257 dot 639431 at consult dot pretender>
> 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