You can use sudo in Windows 11, too — here’s how

In the realm of operating systems, the command sudo has long been a staple for users of Linux-based environments, granting them the ability to execute commands with elevated permissions. This functionality has allowed users to perform critical system tasks that are otherwise restricted. Historically, Windows users have not enjoyed a similar convenience, often requiring them to open an elevated Command Prompt or Windows Terminal for administrative tasks. While the runas command provided some flexibility, it necessitated specifying a user, which could be cumbersome.

With the introduction of Windows 11 version 24H2, Microsoft has taken a significant step by integrating its own version of sudo. This enhancement simplifies the process of executing commands with administrator privileges, making it more accessible for users.

How to set up sudo

Using the Settings app

Although sudo is available in Windows 11 version 24H2, it is not activated by default. To enable it, follow these steps:

  1. Open the Settings app.
  2. Navigate to the System section and scroll to find the For developers option.
  3. At the bottom of the page, toggle the Enable sudo option to On.

Additionally, users can customize the behavior of sudo. By clicking the arrow next to the toggle, options are available to dictate how applications run. The choices include:

  • In a new window – This option runs the command in a new elevated window, allowing for subsequent commands.
  • With input disabled – This runs the command in a new window but does not accept further input.
  • Inline (recommended) – This executes the command in the current window, displaying results directly.

Using the command line

For those who prefer command-line interfaces, sudo can also be set up via the terminal. By running Windows Terminal or Command Prompt in an elevated session, users can enter the command:

sudo config --enable 

Replace the bolded text with one of the three options mentioned earlier:

  • 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 sudo is enabled, users can simply prepend sudo to any command requiring elevation. For instance:

sudo netstat -ab

This command will provide insights into active internet connections. While most commands function seamlessly with sudo, certain PowerShell commands, such as Get-AppXPackage, may not work as intended, often resulting in a “command not found” error. Additionally, some commands may not display output correctly when set to open in a new window, making the inline option the most user-friendly choice.

Sudo is a fantastic addition

For those less familiar with Linux, the introduction of sudo in Windows represents a significant improvement in usability. It streamlines the process of executing commands that require elevated permissions, mitigating the risks associated with running an entire session in an elevated window. This enhancement not only simplifies user experience but also bolsters security by ensuring that elevated privileges are granted only when necessary.

The demand for sudo in Windows has been palpable, and its arrival is a welcome development. As Microsoft continues to refine this feature, users can look forward to an even more robust experience in the future.

Winsage
You can use sudo in Windows 11, too — here's how