Web lists-archives.com

Re: equivalent to su or sudo?





On 8/17/2018 4:33 PM, David Rothenberger wrote:
> Ulli Horlacher wrote:
>> I need to run some scripts with full administrator rights (for chown,
>> chmod, setfacl).
>> Is there a cygwin equivalent to su or sudo?
>>
> 
> I use the following shell script to start a command as Administrator. I mainly just use it to start mintty.
> 
> #!/bin/bash
> cmd="$(cygpath -da "$1")"; shift
> if [ $# -gt 0 ]; then
>   powershell Start-Process "$cmd" -ArgumentList \""$@"\" -Verb RunAs -WindowStyle Hidden
> else
>   powershell Start-Process "$cmd" -Verb RunAs -WindowStyle Hidden
> fi
> 

You don't need powershell for that.

<file name="/usr/local/bin/runas">
#!/bin/sh
export PS1="% "
cygstart --action=runas mintty --title=Admin -e /bin/bash -il
</file>

The export of PS1 is to mark that the terminal window is in
administrative rights.  You can modify the shell program to dash, ash
zsh or whatever you favorite shell is.  Make sure to issue the
interactive and login support for the shell.

-- 
cyg Simple

--
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