Skip to main content

Comparison between gsudo and Microsoft sudo

gsudo was born in 2019 as a productivity tool and is open-source. It has been downloaded over 700k times so far and has enjoyed a warm reception from users. It is very easy to install and works from Windows 7 SP1 up to Windows 11.

Microsoft initially declined to create a similar tool, citing security concerns. However gsudo's documentation challenged this view arguing that absolute security is unattainable without altering Windows itself, and that the default same-desktop UAC is not completely secure either.

In February 2024, Microsoft reversed its stance and released Sudo for Windows.

Surprisingly, Microsoft's sudo does not leverage new OS features to enhance security. Its mechanisms are akin to gsudo, making their security models comparable. The question of which one is more secure depends on which version of each are you comparing, and how many open bugs it has. The initial release of Microsoft's sudo presented some critical issues that they will hopefully address very soon. gsudo has fixed similar issues in the past and may in the future.

Sudo Tools Feature Comparison

Is it a proper Sudo tool?

FeaturegsudoSudo for Windows
Executes command with elevated permissionsYesYes
Supports output redirection (sudo dir > file.txt)YesYes
Supports input redirection (echo md SomeFolder \| sudo cmd)YesYes
Returns the command exit codeYesYes
Preserves the current directoryYesYes, except in new-window mode! ⚠️ Learn More
Source code availableYesYes

Security Impersonation Features

FeaturegsudoSudo for Windows
Run with custom IntegrityYes (-i, --integrity)No
Run as SystemYes (-s, --system)No
Run as TrustedInstallerYes (--ti)No
Run as userYes (-u user)No

User Experience

FeaturegsudoSudo for Windows
Easy to install and updateYes (winget, choco, scoop)No (Windows Insider build required)
See less UAC Pop-upsYes (Credentials Cache)No
Elevate current shellYesNo
Elevate commands using current shellYesNo
Red # indicator for elevation on CMDYesNo

Additional Features

FeaturegsudoSudo for Windows
Run in new windowYesYes
Option to keep new window open until a key is pressedYesNo
Option to keep new window's shell openYesNo
Run with Input DisabledYesYes
Elevate last command with sudo !!YesNo

PowerShell

FeaturegsudoSudo for Windows
Elevation syntaxgsudo { scriptblock } -args $a,$b syntaxsudo pwsh { scriptblock } -args $a,$b (Unofficial!)
Auto-complete of last 3 commandsYes (with gsudoModule)No
Auto-complete of command line argumentsYes (with gsudoModule)No
Red # indicator for elevationYes (with gsudoModule)No

What if I install both?

If you have both Microsoft Sudo and gsudo installed, they both should work independently.

The sudo keyword will run Microsoft's sudo instead of gsudo because the typical install of Sudo for Windows puts it in c:\Windows\System32\sudo.exe. This folder appears first in the PATH environment variable, therefore when running sudo, the Microsoft sudo.exe will take precedence over gsudo's sudo alias.

With the release of gsudo v2.5.0, a new configuration setting called PathPrecedence has been added. When set to true, it ensures gsudo appears first in the PATH variable, making the sudo keyword start gsudo instead of Microsoft's sudo. To activate, call gsudo config PathPrecedence true and restart all consoles to apply the change. Setting it back to false will revert to the normal behavior.

Additionally, gsudo now supports Microsoft sudo styled arguments such as --inline, --disable-input, --preserve-env, --new-window, and -D / --chdir {directory}, ensuring a smoother transition for users familiar with Microsoft sudo.