Enable and Configure Sudo for Windows 11 to Run Admin Commands Faster

Sudo for Windows lets you prefix a command with sudo to run it as administrator from a normal, unelevated terminal. It is built into Windows 11 version 24H2 and later, starting with OS build 26100. It is not available as a built-in feature on Windows 10 or Windows 11 version 23H2 and earlier.

Prerequisites and compatibility​

Before enabling Sudo for Windows, confirm the following:
  • Windows 11 version 24H2 or later is installed.
  • You can approve a User Account Control (UAC) prompt or provide administrator credentials.
  • The computer is not subject to an organizational policy that disables or restricts sudo.
  • UAC remains enabled. Windows sudo uses UAC rather than requesting a password inside the terminal.
  • No restart is normally required after enabling or reconfiguring sudo.
To check the Windows version:
  1. Press Windows key + R.
  2. Enter:
    winver
  3. Select OK.
  4. Confirm that the dialog reports Version 24H2 or later. Version 24H2 should have build 26100 or a higher servicing build.
If the computer runs an earlier version, open Settings > Windows Update, select Check for updates, install the available feature update, and restart when Windows Update requests it.

Windows 10 support​

Windows 10 does not include Microsoft’s sudo.exe command or an Enable sudo setting. Continue using one of these methods instead:
  • Right-click Terminal, PowerShell, or Command Prompt, and select Run as administrator.
  • From PowerShell, run:
    Start-Process powershell.exe -Verb RunAs
  • Use runas when a program must run under another user account. Unlike sudo, runas is intended for changing the user identity and can request that account’s password.

Enable and configure Sudo for Windows​

1. Open the correct Settings page​

The location changed between Windows 11 releases.
Windows 11 version 25H2 and later:
  1. Open Settings.
  2. Select System.
  3. Select Advanced.
  4. Find or expand the Terminal section.
Windows 11 version 24H2:
  1. Open Settings.
  2. Select System.
  3. Select For developers.
  4. Locate the Enable sudo setting.
You can also press Windows key + R, enter the following command, and select OK:
ms-settings:developers
This opens the applicable advanced or developer settings page for the installed Windows release.

2. Review the security implications​

Warning: Sudo launches a selected process with administrator-level permissions. An incorrect command can modify protected files, services, accounts, disks, networking, or Windows configuration. Verify the complete command before approving UAC, especially when copying commands from websites, scripts, chat messages, or package documentation.
Sudo supports three operating modes:
Mode in SettingsCommand-line nameBehaviorRecommended use
In a new windowforceNewWindowRuns the elevated process in a separate console windowSafest general-purpose choice
Input closeddisableInputRuns in the current window but prevents the elevated process from receiving terminal inputNoninteractive commands
InlinenormalRuns in the current window and allows the elevated process to receive inputInteractive tools when the risk is understood
In a new window is the default and recommended configuration. It provides a stronger separation between the normal terminal and the elevated process.
Input closed is useful for commands that produce output but do not ask questions or open an interactive prompt. A command that expects keyboard input may appear stuck, fail, or exit when this mode is selected.
Warning: Inline is the most convenient mode but has the greatest exposure. Because the elevated process shares the current console and can receive input from it, another unelevated process associated with that console may attempt to send input to the elevated process or observe its output. Use Inline only on a trusted computer and in terminal sessions that are not running untrusted scripts or programs.

3. Turn on sudo​

  1. Set Enable sudo to On.
  2. Approve the User Account Control prompt.
  3. If signed in with a standard account, enter credentials for an administrator account when requested.
  4. Wait for the toggle to remain in the On position.
The change takes effect immediately. A Windows restart is not normally required.

4. Select the operating mode​

Under Configure how sudo runs applications, select one of the following:
  • In a new window for the safest default behavior.
  • Input closed for noninteractive elevated commands that should return output to the current terminal.
  • Inline for interactive commands that must remain in the current terminal.
For most users, start with In a new window. Change modes only when a specific command requires current-window output or interactive input.

5. Open a normal terminal​

Sudo is designed to be started from a terminal that is not already elevated.
  1. Open Start.
  2. Search for Terminal.
  3. Select Terminal normally. Do not select Run as administrator.
  4. Open either a PowerShell or Command Prompt tab.
If the terminal tab displays Administrator in its title, close it and open a normal window. Sudo will still run from an elevated terminal, but that does not test its intended elevation behavior.

6. Run an administrative command​

Prefix the command requiring elevation with sudo. For example:
sudo netstat -ab
Expected behavior:
  1. Windows displays a UAC confirmation prompt.
  2. After approval, netstat runs with administrator permissions.
  3. Depending on the configured mode, the command runs in a separate window or returns its output to the current terminal.
The -b option asks netstat to identify the executable associated with each connection or listening port, which normally requires elevation.
Other examples include:
sudo notepad C:\Windows\System32\drivers\etc\hosts
sudo diskpart
Warning: The first example opens the protected hosts file in an elevated editor. Do not save changes unless you intend to alter name resolution. The second opens DiskPart, which can delete partitions and data if given the wrong command. For a basic test, use sudo netstat -ab instead.

Verify that sudo is working​

Verify the executable​

In PowerShell, run:
Get-Command sudo
A working installation should identify sudo.exe, normally under C:\Windows\System32.
In Command Prompt, use:
where sudo
Expected result:
C:\Windows\System32\sudo.exe

Verify elevation in New window or Inline mode​

Run:
sudo cmd /k whoami /groups
Approve UAC. In the output, locate:
Mandatory Label\High Mandatory Level
That entry confirms that the command received a high-integrity administrative token. When finished, enter:
exit
In New window mode, the elevated Command Prompt opens separately. In Inline mode, it uses the current console session.

Verify elevation in Input closed mode​

Because Input closed prevents the elevated process from accepting keyboard input, use a command that exits automatically:
sudo whoami /groups
Look for:
Mandatory Label\High Mandatory Level
If that entry appears and the command returns to the prompt, sudo is enabled and elevation succeeded.

Configure sudo from the command line​

The Settings interface is the simplest method, but the command line is useful for scripting initial setup or recovering from a Settings toggle that does not apply correctly.
The configuration command must be run from an already elevated Terminal, PowerShell, or Command Prompt.
  1. Right-click Start.
  2. Select Terminal (Admin).
  3. Approve UAC.
  4. Run one of the following commands.
Enable the recommended separate-window mode:
sudo config --enable forceNewWindow
Enable current-window operation with input disabled:
sudo config --enable disableInput
Warning: The following command enables Inline mode. This permits the elevated process to receive input from the same console used by unelevated processes. Do not use it in a console that is hosting untrusted software or scripts.
Enable Inline mode:
sudo config --enable normal
Close the elevated terminal, open a normal Terminal window, and run the verification command for the selected mode. No restart should be required.

Troubleshooting​

sudo is not recognized as a command​

First check the Windows version with:
winver
Sudo requires Windows 11 version 24H2, build 26100 or later. It cannot be enabled on Windows 10, Windows 11 23H2, or an older release merely by adding a Settings or registry value.
If the version is supported:
  1. Close every Terminal, PowerShell, and Command Prompt window.
  2. Open a new terminal.
  3. Run:
    where sudo
  4. Check whether this file exists:
    C:\Windows\System32\sudo.exe
If the file is missing, install current Windows updates and restart. If Windows Update reports the system as current but the executable is still absent, repair Windows system files from an elevated terminal:
DISM.exe /Online /Cleanup-Image /RestoreHealth
After DISM finishes, run:
sfc /scannow
Restart Windows after the repairs and check again.

The Enable sudo setting is missing​

Verify both possible locations:
  • Windows 11 24H2: Settings > System > For developers
  • Windows 11 25H2 and later: Settings > System > Advanced > Terminal
If neither location contains Enable sudo, confirm the Windows version and install pending cumulative or feature updates.
On a work or school computer, the setting may be hidden or controlled by policy. Administrators can configure sudo under:
Computer Configuration > Administrative Templates > System > Configure the behavior of the sudo command
A device policy can disable sudo or limit the highest-risk mode users are allowed to select. Do not attempt to bypass organizational policy; contact the device administrator.

The toggle is unavailable or returns to Off​

Open Terminal (Admin) and try the command-line configuration:
sudo config --enable forceNewWindow
If the command reports that sudo is disabled by policy, the local Settings toggle cannot override that policy. Check Local Group Policy on a personally managed Pro, Enterprise, or Education installation. On an organization-managed device, escalate the issue to the administrator.

UAC appears, but the command does not run​

If No was selected or the prompt was closed, run the command again and approve it.
A standard user must provide valid administrator credentials. Sudo does not bypass UAC, grant administrator membership, or elevate an account without authorization.
Also confirm that the command itself is valid by running its non-administrative form. For example:
netstat -ab
An access-related error is expected without elevation, but an error stating that the command or option is invalid indicates a command syntax problem rather than a sudo problem.

The command opens another window​

Sudo is configured as In a new window. This is normal and is the recommended default.
To use the current terminal, select Input closed or Inline under Configure how sudo runs applications. Use Input closed for commands that do not require keyboard input.

An interactive program does not accept keyboard input​

Sudo is configured as Input closed. That mode intentionally closes the input handle so the elevated process cannot receive input from the current console.
Change the mode to In a new window for the safer interactive option. Use Inline only after reviewing its security implications.

Pipes or redirection still receive an access-denied error​

The current unelevated shell normally processes operators such as >, |, and &&. Prefixing only the first executable with sudo may therefore leave another part of the command running unelevated.
Wrap the complete operation in an elevated shell. For Command Prompt syntax:
sudo cmd /c "command1 | command2 > C:\protected-path\output.txt"
Replace the example commands and path with the required operation. Confirm the destination and full command before approving UAC because the entire wrapped command runs elevated.

Sudo does not run the command as another user​

Windows sudo currently elevates a process as administrator; it does not provide the general “run as another user” behavior available through runas.
Use:
runas /user:ComputerName\UserName "program.exe"
Replace the computer and user names as appropriate. runas may prompt for the target account’s password in the terminal.

sudo behaves differently inside WSL​

Sudo for Windows applies to Windows executables launched from Windows Terminal, PowerShell, or Command Prompt. A Linux distribution running under Windows Subsystem for Linux has its own Linux sudo command, configuration, password handling, and permissions.
Use Windows sudo from a Windows shell:
sudo netstat -ab
Use the distribution’s Linux sudo after entering WSL:
sudo apt update
The two implementations are separate.

Disable sudo or restore the safer configuration​

To keep sudo available but restore the recommended mode:
  1. Open the applicable Settings page:
    • Windows 11 24H2: Settings > System > For developers
    • Windows 11 25H2 or later: Settings > System > Advanced > Terminal
  2. Under Configure how sudo runs applications, select In a new window.
  3. Close and reopen Terminal.
  4. Run sudo netstat -ab and confirm that the elevated command opens separately.
To disable sudo completely:
  1. Return to the same Settings page.
  2. Set Enable sudo to Off.
  3. Approve UAC if prompted.
  4. Open a new normal terminal.
  5. Run:
    sudo netstat -ab
Windows should report that sudo is disabled rather than launching the administrative command. If sudo remains enabled or the control is locked, a device management or Group Policy setting is controlling it; review Computer Configuration > Administrative Templates > System > Configure the behavior of the sudo command or escalate the change to the organization’s Windows administrator.

References​

  1. Official source: github.com
  2. Official source: docs.github.com
  3. Official source: gist.github.com
 

Back
Top