Introduction to gsudo
masterOverview
gsudo is a sudo equivalent for Windows, providing a user experience similar to the original *nix sudo. It allows you to run commands with elevated permissions or elevate your current shell within the same console window (or a new one if specified).
Core Capabilities
- Elevate Commands: Prepend
gsudo(or thesudoalias) to any command to run it with elevated permissions. - In-place Execution: Elevated commands run in the current user-level console without opening a new window (unless the
-nflag is used). - Shell Integration:
gsudouses your current shell to interpret commands. For example, in PowerShell,gsudo mkdir xexecutespwsh -c "mkdir x". - Script Support:
- Returns the command's exit code via
%errorlevel%. - If elevation fails, it returns exit code
999. - If already running in an elevated console,
gsudoruns the command as-is without requiring further elevation or showing a UAC popup.
- Returns the command's exit code via
- Last Command Elevation: Use
gsudo !!to elevate the last command executed (supported in CMD, Git-Bash, MinGW, MSYS2, Cygwin, and PowerShell with thegsudomodule installed).