Microsoft has exciting news for Windows developers and power users - they have open sourced the code for Sudo for Windows!
Sudo (superuser do) is a popular tool on Linux and Unix systems that allows users to run commands with elevated/administrator privileges from a non-elevated terminal session.
What is Sudo for Windows?
Recently introduced in Windows 11 Insider Preview Build 26052, Sudo for Windows brings a similar functionality to run elevated commands directly from an unelevated command prompt or PowerShell window with just the sudo prefix.
Instead of having to start a new admin terminal every time you need to run a privileged command, you can now simply use sudo right from your current terminal session. This can save time and provide a smoother workflow.
For example, to run the netstat
command with admin rights, instead of opening a new elevated Command Prompt, you can just run:
sudo netstat -ab
You will be prompted to verify the elevation, and the command will run with administrator access within your current terminal.
How to Enable Sudo in Windows
To use Sudo for Windows, you must be on Windows 11 Insider Preview Build 26052 or newer. You can then enable it by going to Settings
> System
> For Developers
and turning on the "Enable sudo" option.
Three Configuration Options
Sudo for Windows offers three different configuration modes you can choose from:
- In a new window (forceNewWindow) - This is the default mode that runs the elevated command in a new window, similar to
runas
. - Input closed (disableInput) - Runs the elevated process inline but with input disabled to the process for security.
- Inline (normal) - Runs the elevated process inline with input allowed, most closely matching traditional sudo behaviour.
The inline modes provide convenience but have higher security considerations compared to the isolated new window mode.
Open Source and Contributing
Microsoft has now open sourced the Sudo for Windows code on GitHub to allow community contributions and feedback. You can check the GitHub Repo.
They have also open sourced a sudo.ps1
PowerShell script that aims to provide a more user-friendly sudo experience in PowerShell.
While sudo is a new addition to the Windows world, it has the potential to boost productivity for developers, IT pros and power users by allowing quick elevation of commands without context switching.
With Microsoft now open sourcing the project, the community can help shape and improve the sudo experience on Windows.