By Lydia | Last Updated
In Windows 11 version 24H2, Microsoft introduced a Sudo command similar to Linux Sudo. Here is detailed introduction of Windows Sudo, including ways to enable and use Windows 11 Sudo command.
Sudo for Windows is currently only available to users running Windows Insider Preview builds or higher. Other users who wish to use it need to register to join the Windows Insider program. You can find it on Windows 11 Canary builds and it may be progressively rolled out to stable builds throughout the year.
The term "sudo" stands for "superuser do", allowing regular users to execute commands with superuser privileges on specific commands. To be simplified, it enables non-root users to run commands that typically require root privileges.
It speeds up administrative tasks, and primarily achieves the following:
1. Execute commands as another user without needing to log into their account.
2. Provide a more secure method to grant users elevated access.
3. Spend less time writing runas commands.
Step 1: Open Settings > System > For developer.
Step 2: Turn on "Developer Mode" and then confirm to use developer features.
Step 3: Enable the "Enable sudo" option under the Developer options.
Step 4: Once configured, you can use sudo in both the regular command prompt and PowerShell to execute operations that require administrator privileges.
Steps: Right-click on Windows, choose Terminal. Run the following command:
sudo config --enable <configuration_option>
You can replace "<configuration_option>" with "forceNewWindow", "disableInput", or "normal" based on your preferences.
On the "Developer settings" interface, there are 3 options for configuring sudo command behavior:
1. In a new window: When using sudo to run commands, it opens a new window with administrator privileges and executes the command there.
2. With input disabled: A security feature where when running sudo commands, the command executes in a new window and does not accept additional input. This temporarily disables keyboard or mouse input to prevent unauthorized actions during execution.
3. Inline: Allows sudo commands to execute in the current window or relevant context, similar to Linux and macOS.
To run commands with administrative privileges using the sudo command in Windows, simply type "sudo" in the command.
Take following command as example, it fails if executed without "sudo" because it is only available to users in an elevated administrative session.
sudo del mytextfile.txt
You can also achieve similar functionality by using PowerShell or Command Prompt with administrative privileges, and by creating a shortcut that allows standard users to run applications as administrators, speeding up administrative tasks in Windows.
Windows 11 currently only has few options for sudo now, whereas Linux has around 20. Using the command below to check the options:
sudo -h