Root user/sudo equivalent in Cygwin?

后端 未结 17 2277
旧时难觅i
旧时难觅i 2020-12-04 04:23

I\'m trying to run a bash script in Cygwin.

I get Must run as root, i.e. sudo ./scriptname errors.

chmod 777 scriptname does no

17条回答
  •  感情败类
    2020-12-04 05:11

    What I usually do is have a registry "Open Here" helper in order to open a cygwin shell with administrative privileges quite easy from anywhere in my computer.

    Be aware you have to have the cygwin "chere" package installed, use "chere -i -m" from an elevated cygwin shell first.

    Assuming your cygwin installation is in C:\cygwin...

    Here's the registry code:

    Windows Registry Editor Version 5.00
    
    [-HKEY_CLASSES_ROOT\Directory\shell\cygwin_bash]
    
    [HKEY_CLASSES_ROOT\Directory\shell\cygwin_bash]
    @="Open Cygwin Here as Root"
    "HasLUAShield"=""
    
    [HKEY_CLASSES_ROOT\Directory\shell\cygwin_bash\command]
    @="c:\\cygwin\\bin\\mintty.exe -i /Cygwin-Terminal.ico -e /bin/xhere /bin/bash.exe"
    
    [-HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash]
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash]
    @="Open Cygwin Here as Root"
    "HasLUAShield"=""
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash\command]
    @="c:\\cygwin\\bin\\mintty.exe -i /Cygwin-Terminal.ico -e /bin/xhere /bin/bash.exe"
    
    [-HKEY_CLASSES_ROOT\Drive\shell\cygwin_bash]
    
    [HKEY_CLASSES_ROOT\Drive\shell\cygwin_bash]
    @="Open Cygwin Here as Root"
    "HasLUAShield"=""
    
    [HKEY_CLASSES_ROOT\Drive\shell\cygwin_bash\command]
    @="c:\\cygwin\\bin\\mintty.exe -i /Cygwin-Terminal.ico -e /bin/xhere /bin/bash.exe"
    

    Hope this helps. Let me know if it works for you. Thanks.

    PS: You can grab this code, copy and paste it and save it in a name.reg file to run it... or you can manually add the values.

提交回复
热议问题