What is gsudo, and how to get started? The better Linux Sudo for Windows 11 and 10 explained.

You can bring the Linux Sudo command to older version of Windows 11 and 10 with gsudo, and here's how.

Gsudo for Windows
Gsudo for Windows / Image: Mauro Huculak
  • To install gsudo on Windows 11 or 10, open Command Prompt (admin) and run the winget install --id gerardog.gsudo command.
  • You can now run elevated commands using the gsudo YOUR-COMMAND, or you can use the sudo alias, for instance, sudo YOUR-COMMAND.

Gsudo is a better alternative that brings the Linux sudo command experience to Windows 11, 10, and older versions, and in this guide, I will show you how to get started.

Starting on version 24H2, Windows 11 incorporates the sudo command natively. However, unlike the version available on Linux, the one for Windows is very limited in terms of the options you can use. If you want a more similar experience to the version on Linux, you have to use the gsudo tool.

Also, Windows 10 doesn’t include native support for sudo, but gsudo tool brings the ability to elevate commands for older versions of the operating system, including Windows 8.1 and 7 SP1.

What’s gsudo?

Gsudo is basically the sudo command for Linux but for Windows users since it offers virtually the same experience to run commands elevated with administrator permissions without having to reopen the Command Prompt, PowerShell, WSL console, and many others.

The gsudo is a third-party portable tool created by Gerardo Grignoli available through the GitHub platform, and anyone can install it on Windows 11 as well as on Windows 10 through the various package managers, including the Windows Package Manager (winget).

The tool uses “gsudo” to run elevated commands, but the “sudo” alias is also supported. However, since Windows 11 24H2 already integrates “sudo,” it’s best to use the “gsudo” command. On Windows 10 22H2, the “sudo” alias works flawlessly.

In this guide, I will explain the easy steps to install and run your first command with gsudo on Windows 11 and 10.

Install and run sudo commands with gsudo on Windows

To install gsudo to run sudo commands on Windows 11 or 10, use these steps:

  1. Open Start on Windows.

  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.

  3. Type the following command to install gsudo and press Enter:

    winget install --id gerardog.gsudo

    winget install gsudo

  4. Restart the command shell as a standard user.

  5. (Option 1) Type the following command to run a command elevated and press Enter:

    gsudo YOUR-COMMAND

    For example, this command deletes a text file for the root of the “C” drive: gsudo del mytext.txt

    Run sudo command with gsudo

  6. (Option 2) Type the following command to run the gsudo command as sudo and press Enter:

    sudo YOUR-CAMMAND
  7. Type the following command to run the last command again and press Enter:

    gsudo !!
  8. (Optional) Open Start.

  9. Search for PowerShell and click the top result to open the shell.

  10. Type the following command to run gsudo on PowerShell and press Enter:

    gsudo { YOUR-COMMAND }

    For example, this command prints the “Hello World” messages in PowerShell: gsudo { Write-Output "Hello World" }.

    PowerShell gsudo run sudo command

    Quick note: When using gsudo with PowerShell, you have to make sure to wrap the command with curly braces {}. If you’re specifying a variable $, create the variable as you would normally do, and then call the variable in the command with gsudo. For example, in the first line, use the $MyString = "Hello World" command, press “Enter,” and then run the gsudo { Write-Output $args[0] } -args $MyString command.
  11. (Optional) Type the following command to confirm the version of the tool and press Enter:

    gsudo -v
  12. (Optional) Type the following command to view the available options and press Enter:

    gsudo /?

    gsudo options for Windows

Once you complete the steps, the command will run elevated from a standard command shell without the need to relaunch the console.

If you look at the “sudo” and “gsudo,” the biggest differences are that one is the native integration, and the other is a third-party application. However, while the “sudo” command can delete protected files, elevate commands, and open new elevated shell sessions, the “gsudo” can perform these tasks in addition to many other actions.

For example, you can cache a session to reduce the number of admin prompts. It’s possible to create a new window with different options. You’ll find more security settings and many other options.

It’s important to note that if you only need the basic functionalities, the native “sudo” support is perhaps all you need. Also, if you install this third-party tool on a device running version 24H2, it’s best to use the “gsudo” command rather than “sudo” since there could be conflicts.

The gsudo command is best supported for computers running Windows 11 23H2 and older releases and for bringing the “sudo” command to Windows 10.

What are your thoughts about this third-party tool? Let me know in the comments.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 15 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 21 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me. Email him at [email protected].