Sudo for Windows lets you run a command with administrator rights from a terminal opened normally, for example sudo netstat -ab. When the command does not behave as expected, the message shown almost always points to the cause: Windows too old, feature not turned on, feature blocked by a policy, or an unexpected run mode.
Observe before acting
Type winver (Windows key + R, then Enter) and note the version shown. Microsoft states that Sudo for Windows is available from Windows 11 version 24H2. On Windows 10 or Windows 11 23H2, the command does not exist.
| What you see | Most likely cause | Step |
|---|---|---|
| sudo is not recognized, Windows older than 24H2 | Feature missing from this version | Step 1 |
| "Sudo is disabled on this machine" | Feature not turned on in Settings | Step 2 |
| "Sudo is disabled by your organization's policy" | Group Policy or enterprise management | Step 3 |
| New window that closes, output not visible | Default "new window" mode | Step 4 |
| "You must run this command as an administrator" | sudo config run without elevation | Step 4 |
Step 1: check that your Windows supports sudo
When to use it: the sudo command is not recognized at all.
Expected result: after moving to 24H2 or later, the sudo option appears in Settings (step 2).
Rollback: none, this step changes nothing.
Step 2: turn on sudo in Settings
When to use it: the message "Sudo is disabled on this machine" is shown.
Microsoft warns that, in some configurations, sudo can be used as a potential privilege escalation vector. Only turn it on if you actually need it.
Expected result: a User Account Control window appears, then the command runs elevated.
Rollback: turn the same option off in Settings.
Step 3: sudo blocked by a policy
When to use it: "Sudo is disabled by your organization's policy", or the option is greyed out in Settings.
The Microsoft policy Configure the behavior of the sudo command (file Sudo.admx, Pro, Enterprise, Education and IoT editions) can disable sudo or force a mode. It relies on the EnableSudo value of the Software\Policies\Microsoft\Windows\Sudo key: 0 = disabled, 1 = force new window, 2 = disable input, 3 = normal.
Expected result: the command returns nothing (no policy), and the option can be changed again in Settings.
Rollback: set the policy back to the state you noted before the change.
Step 4: choose the right run mode
When to use it: sudo works, but not the way you expect.
Microsoft describes three modes:
| Mode | Behaviour | Microsoft's remark |
|---|---|---|
| forceNewWindow (default) | The command opens in a new window | Most cautious mode |
| disableInput | The command runs in the current window, without reading the keyboard | Reduced risk |
| normal (inline) | Behaviour closest to sudo on Linux and macOS | A non-elevated process can send input to the elevated process |
Expected result: the next command run with sudo follows the chosen mode.
Rollback: sudo config --enable forceNewWindow (the default mode).
What sudo does not do
- sudo cannot run a command as another user account: Microsoft states that this is the job of runas.
- The User Account Control prompt is still required: sudo does not bypass the confirmation.
- Microsoft's examples launch programs (such as netstat). To chain several PowerShell cmdlets, a Terminal (Admin) is simpler. If a script is refused, see our guide "Running scripts is disabled" in PowerShell.
Final check
- ☐ winver shows Windows 11 version 24H2 or later.
- ☐ The sudo option is turned on in Settings.
- ☐ No EnableSudo policy set to 0 is applied.
- ☐ sudo netstat -ab triggers User Account Control, then shows the output.
Sources
- Microsoft Learn: Sudo for Windows (French version: Sudo pour Windows)
- Microsoft Learn: Policy CSP - Sudo
- Microsoft GitHub: microsoft/sudo
Still having the problem?
Reply to this topic with the version shown by winver, your Windows edition (Home, Pro…), whether the PC is managed by an organization, the command you ran and the exact message. Replace user and machine names with fictitious values.