Configure the behavior of the sudo command
Supported on: At least Windows 11
When the GPO stops applying: Windows removes the value (it is under a Policies branch). How cleanup works
| Registry key | HKLM\Software\Policies\Microsoft\Windows\Sudo |
|---|
| Option | Value | Type | Allowed values |
|---|---|---|---|
| Maximum allowed sudo mode | Enabled | 0 (REG_DWORD) = Disabled 1 (REG_DWORD) = Force new window 2 (REG_DWORD) = Disable input 3 (REG_DWORD) = Normal |
What it does (vendor explanation)
This policy setting controls use of the sudo.exe command line tool.
If you enable this policy setting, then you may set a maximum allowed mode to run sudo in. This restricts the ways in which users may interact with command-line applications run with sudo. You may pick one of the following modes to allow sudo to run in:
"Disabled": sudo is entirely disabled on this machine. When the user tries to run sudo, sudo will print an error message and exit.
"Force new window": When sudo launches a command line application, it will launch that app in a new console window.
"Disable input": When sudo launches a command line application, it will launch the app in the current console window, but the user will not be able to type input to the command line app. The user may also choose to run sudo in "Force new window" mode.
"Normal": When sudo launches a command line application, it will launch the app in the current console window. The user may also choose to run sudo in "Force new window" or "Disable input" mode.
If you disable this policy or do not configure it, the user will be able to run sudo.exe normally (after enabling the setting in the Settings app).
Group Policy path: Computer Configuration > Administrative Templates > System > Configure the behavior of the sudo command
PowerShell equivalent (generated from the template)
# Maximum allowed sudo mode
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\Sudo' -Name 'Enabled' -Value 0 -PropertyType DWord -ForceGroup Policy or Intune is the supported way to set policies. Writing the same values directly works like a local policy and is removed by nothing: delete the values to return to "Not configured".