How to install sudo on Windows 11

No, this is not a troll post. Microsoft really did release sudo for Windows 11. Currently it is available only on Windows 11 Insider Preview Build 26052

So, if you do not want to go through the hassle of getting insider preview builds, just wait a little bit longer.

How to enable sudo in insider preview

Go to Settings -> For Developers, and find the toggle that says Enable Sudo

Not done yet, read the next part

Configuring sudo

As you can see there is an option to Configure how sudo runs applications

This determines how sudo behaves when you run a command. By default it will open the new sudo command in  a new window, which is the most secure option, but it is kinda inconvenient.

But if you are aware of the security implications, you can change that option to inline. This will behave like how it does in Linux

Testing it

You can now test your shiny new sudo for windows by opening a terminal with command prompt or powershell and run

sudo netstat -a

If you have enabled it properly, you should see the windows UAC prompt asking if you want to allow it or not, similar to when you try to install a program. Say Yes and you should see the netstat output