Open in the explorer

Configure the behavior of the sudo command

Configurer le comportement de la commande sudo

Type
Computer
GPO path
Computer Configuration › Policies › Administrative Templates › System FR: Configuration ordinateur › Stratégies › Modèles d'administration › Système
Supported on
At least Windows 11 FR: Au minimum Windows 11
ADMX file
Sudo.admx
Internal name
Sudo/EnableSudo

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).

French text from Windows 11 26H2

Ce paramètre de stratégie contrôle l’utilisation de l’outil de ligne de commande sudo.exe.

Si vous activez ce paramètre de stratégie, vous pouvez définir un mode maximum autorisé pour l’exécution de sudo. Cette option limite la manière dont les utilisateurs peuvent interagir avec les applications en ligne de commande exécutées avec sudo. Pour permettre à sudo de fonctionner, vous pouvez choisir l’un des modes suivants :

« Désactivé » : sudo est entièrement désactivé sur cet ordinateur. Lorsque l’utilisateur essaie d’exécuter sudo, celui-ci affiche un message d’erreur et se ferme.

« Forcer une nouvelle fenêtre » : Lorsque sudo lance une application en ligne de commande, celle-ci est lancée dans une nouvelle fenêtre de console.

« Désactiver l’entrée » : Lorsque sudo lance une application en ligne de commande, celle-ci est lancée dans la fenêtre de console courante, mais l’utilisateur ne peut pas saisir de données dans l’application en ligne de commande. L’utilisateur peut également choisir d’exécuter sudo en mode « Forcer une nouvelle fenêtre ».

« Normal » : Lorsque sudo lance une application en ligne de commande, celle-ci est lancée dans la fenêtre de console courante. L’utilisateur peut également choisir d’exécuter sudo en mode « Forcer une nouvelle fenêtre » ou « Désactiver la saisie ».

Si vous désactivez cette stratégie ou ne la configurez pas, l’utilisateur pourra exécuter sudo.exe normalement (après avoir activé le paramètre dans l’application Paramètres).

Registry

HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Sudo
Value name
not defined in the ADMX

Enable / disable values: not defined in the ADMX (see the options below).

PowerShell

PowerShell commands that write to the registry what the policy would write. Values in angle brackets (<…>) must be replaced.

Writing directly to the registry bypasses Group Policy: if a GPO manages this value, it will be rewritten at the next gpupdate; otherwise the value stays in place (the "tattooing" effect). Prefer a GPO or, locally, LGPO.exe. Run PowerShell as administrator for HKLM. Some policies need a restart or gpupdate /force.

Enable

# Enable: Sudo/EnableSudo
$k = 'HKLM:\Software\Policies\Microsoft\Windows\Sudo'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
# Maximum allowed sudo mode
# Possible options:
#   Disabled = 0
#   Force new window = 1
#   Disable input = 2
#   Normal = 3
Set-ItemProperty -Path $k -Name 'Enabled' -Value 0 -Type DWord

Disable

# Disable: Sudo/EnableSudo
# No value is written in the "Disabled" state (nothing defined in the ADMX)

Revert to "Not configured"

# Revert to "Not configured": Sudo/EnableSudo
$k = 'HKLM:\Software\Policies\Microsoft\Windows\Sudo'
Remove-ItemProperty -Path $k -Name 'Enabled' -ErrorAction SilentlyContinue

Options (1)

LabelControlRegistry valueREG typeConstraints / details
Maximum allowed sudo modeMode sudo maximum autoriséSudoModesDrop-down listenumEnabledREG_DWORD
Default choice (UI): #0
LabelValue
DisabledREG_DWORD = 0
Force new windowREG_DWORD = 1
Disable inputREG_DWORD = 2
NormalREG_DWORD = 3

Availability

Windows 11

✓ 26H2✓ 25H2✓ 24H2— 23H2— 22H2— 21H2

Windows 10

— 22H2— 21H2— 21H1— 20H2— 2004— 1909— 1903— 1809— 1803— 1709— 1703— 1607— 1511— 1507

Windows Server

✓ 2025— 2022— 2016