Open In App

Microsoft is bringing Linux’s Sudo command to Windows 11

Last Updated : 09 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Microsoft persists in its embrace of Linux, solidifying Windows as a welcoming environment for developers.

Microsoft continues to succeed with Linux by bringing the popular ‘sudo’ command to Windows 11. The introduction of ‘Sudo for Windows’ is specifically for developers, giving a solution for running elevated tools directly from an unelevated console session. This move follows Microsoft’s previous actions, including shipping a full Linux kernel in Windows 10 and incorporating Linux features.

Microsoft-Introduces-Sudo-for-Windows-A-Developer-Focused-Command-in-Windows-11-copy

What is ‘Sudo for Windows’?

Microsoft is including the ‘sudo’ command, into Windows 11, popularly used in Unix-based systems like Linux and macOS. ‘Sudo for Windows’ will allow developers to run programs with higher security benefits or as another user directly from an unelevated console session. This provides an efficient and user-friendly approach.

How to Enable Sudo for Windows

For developers excited about ‘Sudo for Windows,’ the process is easy. Follow these simple steps to enable ‘Sudo for Windows’ on your Windows 11 system:

Step 1: Go to “Windows Settings”

Open the Windows Settings app on your device. You can do this by clicking on the Start menu and selecting the gear-shaped icon, or simply pressing the ‘Windows key + I’ shortcut.

Step 2: Go to the “For Developers Page”

Inside the Windows Settings app, find and click on the “Update & Security” section. From there, select the “For Developers” tab in the left-hand menu.

Step 3: Toggle the “Enable Sudo” Option

Once on the ‘For Developers’ page, look for the “Enable Sudo” option. Slide the toggle to the ‘On’ position.

Step 4: Find and Explore the Three Modes

After enabling ‘Sudo for Windows,’ you get access to three modes for running applications.

Step 5: Save Changes

Don’t forget to save your changes by clicking the ‘Apply’ or ‘Save’ button, ensuring the ‘Sudo for Windows’ feature is activated.

How to Configure Sudo for Windows

Configuring Sudo for Windows offers three different options that you can choose from. You can adjust these settings either through the Settings menu or by using the command line. Here are the available configuration options:

In a New Window (forceNewWindow)

By default, Sudo for Windows runs commands in a new window. This setting is similar to how the “runas /user:admin” command works.

Input Closed (disableInput)

With this option, the elevated process runs in the current window, but the input handle is closed. This means the process won’t accept input from the current console window. It’s handy when you need to run a command as an administrator but don’t want it to interact with the current console window.

Inline (normal)

This configuration closely resembles how sudo operates on other operating systems. The elevated process runs in the current window and can accept input from the console session. It’s useful when you want the command to run as an administrator and interact with the current console window. However, be cautious as this option comes with security risks.

You can choose these configurations from the Settings menu or adjust them programmatically using an elevated command line (admin console). Here’s how to do it:

sudo config –enable <configuration_option>

Replace <configuration_option> with either forceNewWindow, disableInput, or normal.

Is Sudo for Windows Safe

Microsoft has been committed to user security since the beginning. With Sudo for Windows, Microsoft assures users of a focus on an easy and secure experience. By activating ‘Sudo for Windows,’ developers will start using a powerful tool that not only improves command execution but also prioritizes the safety of the overall development environment on the Windows platform.

How to Use Sudo for Windows

To use Sudo for Windows, simply insert “sudo” at the beginning of the command you wish to execute with administrator privileges. For example, if you intend to run the command “ipconfig /flushdns” as an administrator, you would enter “sudo ipconfig /flushdns” in your console window.

Since sudo grants elevated permissions to the specified process, a prompt will appear requesting confirmation before proceeding.

Security Considerations

Running sudo in the Input closed (inputClosed) or Inline (normal) configurations comes with certain risks. Malicious processes might attempt to manipulate the elevated process using the connection established by the unelevated sudo.exe and the elevated sudo.exe process.

To address this risk, the inputClosed configuration option closes the input handle. This means that unelevated processes cannot send input to the elevated process since the input handle is disconnected from the current console window.

On the other hand, the inline configuration option runs the elevated process in the current window and allows it to receive input from the current console session. This configuration also enables unelevated processes to send input to the elevated process within the same console window or access information from the output in the current window.

Conclusion

Microsoft’s ‘Sudo for Windows’ shows its efforts to make Windows comfortable for developers, and to be able to create a complete environment that helps with different needs. As developers explored this new feature in Windows 11, they took a step towards a developer-friendly ecosystem. Keep an eye on upcoming Windows updates for ‘Sudo for Windows’.

FAQs on Microsoft Introduces Sudo for Windows

How do I run the sudo command in Windows 11?

The sudo command offers three configuration modes:

Opening in a new window: This mode launches a new window where the elevated command executes.

Input disabled: In this mode, the elevated command runs within the same window as the trigger, but without access to standard input.

Inline (normal) mode: Command runs in current window, allowing admin-level interaction with console. Beware of security risks.

What is the sudo equivalent for Windows 11?

gsudo is like sudo for Windows, working much like it does in Unix/Linux. It lets you run commands with higher permissions or elevate the current shell, whether in the current console window or a new one. Just start your command with gsudo (or the sudo alias) and it will run with elevated privileges.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads