Sudo is a common command in Linux-based operating systems. When using the terminal, entering sudo before a comman allows you to run it with administrator permissions, meaning it allows you to perform certian systems tasks that are blocked off from regular users.
In the past, Windows has lacked somehting like this, so if you ever wanted to execute commands with administrator permissions, you'd specifically have to open a Windows Terminal window (or Command prompt) that's elevated from the start and for the entire session. You could use the runas command, but you'd then have to specify the user to run the command as, which was a bit more cumbersome.
But with Windows 11 version 24H2, Microsoft has implmented its own version of sudo in Windows, so if you want to get started, here's how to use it.
The Windows 11 2024 Update is now available — here's what's new and why it's not Windows 12
The Windows 11 2024 Update will bring a ton of changes to the operating system, including better support for Arm devices.
How to set up sudo
Using the Settings app
While sudo is available in Windows 11 version 24H2, it's not enabled by default, so you'l first need to set it up:
- Open the Settings app.
- Go to the System section and scroll down to find the For developers option.
- Towards the end of the page, switch the Enable sudo toggle to On.
You can also configure how you want sudo to behave. Click the arrow next to the toggle, and you'll see an option to choose how sudo runs applications. You have three choices:
- In a new window - This will run the command in a new elevated window, allowing you to enter follow-up commands if necessary
- With input disabled - This will run the command in a new window, but the window won't accept further input from the user
- Inline (recommended) - This will run the command in the same window you're currently using and output any results in the same window
Using the command line
If you'd rather set up sudo using the command line, you can do that too. While running Windows Terminal (or Command prompt) in an elevated session, enter this command
sudo config --enable <configuration_option>
You'll need to replace the bolded text the argument equivalent to one of the three options above:
- forceNewWindow (to run commands in a new window)
- disableInput (to run commands with input disabled)
- normal (to run commands inline)
Using sudo in the command line
Once you've enabled sudo, you can simply open a regular terminal window and enter sudo before the command you want to use, specifically if it requires elevation. For example, you can try:
sudo netstat -ab
This will show information about connections being established over the internet.
Most commands should work with sudo, though we've noticed some that don't work perfectly. For example, PowerShell commands such as Gat-AppXPackage don't seem to work with sudo, simplying saying "command not found", so operations for installing or removing AppX packages, such as the Game Bar, won't work. Also, some commands may not behave as intended when set to open in a new window, meaning you can't see the output of the commands. Inline is probably the best and easiest way to set it up.
Sudo is a fantastic addition
I'm not much of a Linux user, but you can't deny that sudo makes it a lot easier to run commands that require elevated permissions without having to do mess around having to make sure you opened an elevated window beforehand. THere's also a risk with that kind of approach, since every command run in an elevated window will have administrator privileges without further user verification. Sudo helps enhance security in a way, too.
It's evident from a quick peek online that people have wanted sudo in Windows for a long time, so it's great that it's finally available. Hopefully, it will keep getting improvements in the future for an even better experience.
