Microsoft Brings The Sudo Command To Windows 11 – Here Is How To Enable It

Key Points

  • To enable Sudo for Windows, go to Settings > System > For Developers > Enable sudo.
  • The Sudo command can be configured to run in the following 3 settings: “In a new window“, “With input disabled“, and “Inline” mode; also managed from the “For developers” settings page.

Microsoft is planning to bring the “Sudo” command to Windows 11. Sudo, short for “Superuser do“, is a known Linux-based command that allows users to perform tasks that require elevated privileges. Now, this command is also available for the Windows 11 Terminal.

Microsoft has introduced the Sudo command to the Windows 11 Insider Canary & Dev channels. This release has been announced with the Windows 11 Insider Build 26052. If all goes well, Microsoft will pretty soon introduce the command to Windows 11 stable as well. I anticipate that the Sudo command will be released to the stable channel with Windows 11 24H2 – the next upcoming major feature release.

With the Sudo command, users will no longer be required to launch a process with elevated privileges, such as launching the Command Prompt or PowerShell with administrative rights. Instead, they can run any task with elevated privileges using the Sudo command.

Additionally, Microsoft is making this project open-source. This means that the developers can contribute to it, or manipulate the source code to customize the command. The open-source Sudo command can be found here on GitHub.

The Sudo command will allow users to elevate certain commands while running others with regular (standard) privileges. This is what the Microsoft product manager had to say:

It is an ergonomic and familiar solution for users who want to elevate a command without having to first open a new elevated console.

Microsoft

How to enable and configure Sudo command in Windows

The Sudo command is disabled by default in the Terminal. However, you can enable and configure it from the Settings app. Before I show you how to do that, these are the modes in the Sudo command that can be configured:

  • In a New Window

    In this configuration, the Sudo command will open a new elevated console window and run the command in that window. This is the default configuration option when sudo is enabled.

  • Input Closed

    In this configuration, the Sudo command will run the elevated process in the current window, but the new process will be spawned with its standard input (stdin) closed. This means that the new process will not accept any user input, so this configuration will not work for processes that require further user input after elevation.

  • Inline

    This configuration is most similar to the behavior of sudo on other operating systems, like Linux. In this configuration, Sudo for Windows will run the elevated process with its stdin, stdout, and stderr all connected to the current window. This means the new elevated process can take in input and route output to the current window.

    This makes this mode the most versatile of all.

Now let us see how to enable and configure the Sudo command in Windows 11:

  1. Press the Windows key + i to launch the Settings app.

  2. Go to System.

  3. Click “For developers.”

    Open developer settings
    Open developer settings
  4. Scroll down and toggle the slider in front of “Enable Sudo” to the On position.

    Enable sudo
    Enable sudo
  5. When prompted with a confirmation dialog box, click Yes.

    Confirm enabling the Sudo command
    Confirm enabling the Sudo command
  6. Now click the “Enable sudo” option to expand it.

  7. Expand the drop-down menu and select the mode you want to run the Sudo command in (discussed above).

    Select Sudo command mode
    Select Sudo command mode

Note: The Sudo command settings first appeared in Windows Server. However, according to the Windows 11 Insider Preview Build 26052 announcement, it appeared accidentally and will soon be removed. The Sudo command will not be introduced to the Windows Server.

The setting for enabling Sudo may incorrectly be showing on Windows Server Insider Preview builds – this feature will not be available on Windows Server and the setting will be disabled in a future Server Insider Preview build.

Microsoft

You will now have successfully enabled and configured how you want the Sudo command to run. Now go ahead and run the Sudo command inside the Windows terminal.

Cory Hendrixson from Microsoft has a few tricks to share how you can be productive with the new Sudo command in Windows 11:

To learn more about how the Sudo command works in Windows, refer to this Microsoft guide post.

Conclusion

Windows Subsystem for Linux (WSL) is a Windows component that can also run the “Sudo” command. However, that one is only limited to functions for the Linux distros. With “Sudo for Windows”, users will be able to perform functions similar to that of Linux, but for Windows tasks and operations.

I believe that this new feature will be a new beginning for certain developers that will allow them to work with the Windows OS with just as much control as they get on a Linux PC.

If you liked this post, Share it on:
Subhan Zafar is an established IT professional with interests in Windows and Server infrastructure testing and research, and is currently working with Itechtics as a research consultant. He has studied Electrical Engineering and is also certified by Huawei (HCNA & HCNP Routing and Switching).

Leave the first comment

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information