Sudo for Windows lets you prefix a command with
Windows 11 version 25H2 and later:
This opens the applicable advanced or developer settings page for the installed Windows release.
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.
Expected behavior:
Other examples include:
A working installation should identify
In Command Prompt, use:
Expected result:
Approve UAC. In the output, locate:
That entry confirms that the command received a high-integrity administrative token. When finished, enter:
In New window mode, the elevated Command Prompt opens separately. In Inline mode, it uses the current console session.
Look for:
If that entry appears and the command returns to the prompt, sudo is enabled and elevation succeeded.
The configuration command must be run from an already elevated Terminal, PowerShell, or Command Prompt.
Enable current-window operation with input disabled:
Close the elevated terminal, open a normal Terminal window, and run the verification command for the selected mode. No restart should be required.
First check the Windows version with:
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:
After DISM finishes, run:
Restart Windows after the repairs and check again.
On a work or school computer, the setting may be hidden or controlled by policy. Administrators can configure sudo under:
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.
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.
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:
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.
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.
Change the mode to In a new window for the safer interactive option. Use Inline only after reviewing its security implications.
Wrap the complete operation in an elevated shell. For Command Prompt syntax:
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.
Use:
Replace the computer and user names as appropriate.
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
Use Windows sudo from a Windows shell:
Use the distribution’s Linux sudo after entering WSL:
The two implementations are separate.
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.
- Press Windows key + R.
- Enter:
winver - Select OK.
- Confirm that the dialog reports Version 24H2 or later. Version 24H2 should have build 26100 or a higher servicing build.
Windows 10 support
Windows 10 does not include Microsoft’ssudo.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
runaswhen a program must run under another user account. Unlike sudo,runasis 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:
- Open Settings.
- Select System.
- Select Advanced.
- Find or expand the Terminal section.
- Open Settings.
- Select System.
- Select For developers.
- Locate the Enable sudo setting.
ms-settings:developersThis opens the applicable advanced or developer settings page for the installed Windows release.
2. Review the security implications
Sudo supports three operating modes: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.
| Mode in Settings | Command-line name | Behavior | Recommended use |
|---|---|---|---|
| In a new window | forceNewWindow | Runs the elevated process in a separate console window | Safest general-purpose choice |
| Input closed | disableInput | Runs in the current window but prevents the elevated process from receiving terminal input | Noninteractive commands |
| Inline | normal | Runs in the current window and allows the elevated process to receive input | Interactive tools when the risk is understood |
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
- Set Enable sudo to On.
- Approve the User Account Control prompt.
- If signed in with a standard account, enter credentials for an administrator account when requested.
- Wait for the toggle to remain in the On position.
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.
5. Open a normal terminal
Sudo is designed to be started from a terminal that is not already elevated.- Open Start.
- Search for Terminal.
- Select Terminal normally. Do not select Run as administrator.
- Open either a PowerShell or Command Prompt tab.
6. Run an administrative command
Prefix the command requiring elevation withsudo. For example:sudo netstat -abExpected behavior:
- Windows displays a UAC confirmation prompt.
- After approval,
netstatruns with administrator permissions. - Depending on the configured mode, the command runs in a separate window or returns its output to the current terminal.
-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\hostssudo diskpartWarning: 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, usesudo netstat -abinstead.
Verify that sudo is working
Verify the executable
In PowerShell, run:Get-Command sudoA working installation should identify
sudo.exe, normally under C:\Windows\System32.In Command Prompt, use:
where sudoExpected result:
C:\Windows\System32\sudo.exeVerify elevation in New window or Inline mode
Run:sudo cmd /k whoami /groupsApprove UAC. In the output, locate:
Mandatory Label\High Mandatory LevelThat entry confirms that the command received a high-integrity administrative token. When finished, enter:
exitIn 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 /groupsLook for:
Mandatory Label\High Mandatory LevelIf 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.
- Right-click Start.
- Select Terminal (Admin).
- Approve UAC.
- Run one of the following commands.
sudo config --enable forceNewWindowEnable current-window operation with input disabled:
sudo config --enable disableInputEnable Inline mode: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.
sudo config --enable normalClose 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:winverSudo 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:
- Close every Terminal, PowerShell, and Command Prompt window.
- Open a new terminal.
- Run:
where sudo - Check whether this file exists:
C:\Windows\System32\sudo.exe
DISM.exe /Online /Cleanup-Image /RestoreHealthAfter DISM finishes, run:
sfc /scannowRestart 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
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 commandA 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 forceNewWindowIf 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 -abAn 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 throughrunas.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 -abUse the distribution’s Linux sudo after entering WSL:
sudo apt updateThe two implementations are separate.
Disable sudo or restore the safer configuration
To keep sudo available but restore the recommended mode:- Open the applicable Settings page:
- Windows 11 24H2: Settings > System > For developers
- Windows 11 25H2 or later: Settings > System > Advanced > Terminal
- Under Configure how sudo runs applications, select In a new window.
- Close and reopen Terminal.
- Run
sudo netstat -aband confirm that the elevated command opens separately.
- Return to the same Settings page.
- Set Enable sudo to Off.
- Approve UAC if prompted.
- Open a new normal terminal.
- Run:
sudo netstat -ab
References
- Official source: github.com
Can't activate sudo in settings · Issue #25 · microsoft/sudo · GitHub
Clicking the button in setting does nothing and it reverts a few seconds later. See video of issue at https://t.co/wKHQ9o7Mm6 Also nothing seems to be in registry. Thank you all !
github.com
- Official source: docs.github.com
Sudo mode - GitHub Docs
To confirm access to your account before you perform a potentially sensitive action, GitHub.com prompts for authentication.
docs.github.com
- Official source: gist.github.com
build_linux_kernel.md · GitHub
GitHub Gist: instantly share code, notes, and snippets.
gist.github.com