Screencast
Links
Introduction
Linux and Mac users use the sudo
command naturally in order to execute something with elevated privileges. For Windows users however this always was somewhat
quirky because you either had to start the terminal session as an admin or otherwise hack your way in. This is about to change!
Installation
sudo
is only available on the latest Insider Preview versions of Windows 11. As of the time of this article my current version of Windows is 24H2 (26120.3281)
. After this is installed
you have to enable sudo
in the Windows Settings Developer
-section:
Usage
The simples example is to open a Windows Terminal with privileged access from another terminal. With sudo
this is as easy as:
sudo wt
This command will open the Windows-UAC-confirmation dialog and after you approved the request the screen looks something like this:
This is nice! The next stuff we could do is opening the hosts
file as an Administrator:
> sudo notepad C:\Windows\System32\Drivers\etc\hosts
Now this file opened in the editor can be safed without any issue because the notepad is running as admin.
Other useful examples could be:
sudo choco upgrade all
sudo pwsh Get-ChildItem
and more.
Current limitations
Whatever command you call after sudo
, it needs to be an executable. So sudo ls
will not work. First because it is an alias but more importantly because
this is not a executable file but a PowerShell command and thus not a Windows EXE.
Conclusion
Lets see how this evolves over time and what the final version will look like. Having the option now is already helping me in some of my daily routines. So good, Microsoft!