As many of you already know, Cygwin doesn't have the sudo command, and it's recommended to use the runas command when you need root/administrator privileges. However, using runas creates a new cmd window to run the command in, which is not ideal (for me at least). What I'm looking for is a way to issue a sudo (or su) command and it still run seamlessly within the Cygwin shell. For example, if I want edit /etc/hosts I'd like to do so in the same window I issued the 'nano /etc/hosts' command in.

I've looked around for solutions, and sudo-for-cygwin seems pretty much perfect. Issue is that I can't get it to work (if someone is interested, this is the sudoserver.py code I try to run http://bpaste.net/show/UkMcxguGH2CgR0OXRIyP/ , and this is the error I get when I do so http://bpaste.net/show/nSp8athPoOrteCtffrlO/, and changing the port number does not seem to allow the script to complete). I've not coded in Python before, so unsure on how to debug this.

So I'm looking for ideas. I'm running Cygwin through Console2 (http://sourceforge.net/projects/console/), perhaps I could start Console2 using the Administrator account in some way? Really I'm stuck, so appreciate your input.

Thanks, Tom


You can try ConEmu (I'm an author of it).

It is impossible to elevate process in current console, but you can run elevated (As Admin) process in new (even in background) tab of existing ConEmu window. There is -new_console switch, wich you may use anywhere inside ConEmu tabs. For example:

dism -new_console:a

Thought, you may create batch file sudo.cmd and place it in the %PATH%

%* -new_console:a
| improve this answer | |
  • I don't get it. How do I launch a "superuser" Cygwin shell in ConEmu? (I already use ConEmu routinely) – André Chalella Jul 30 '16 at 2:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.