PowerShell’s New sudo Feature: A Step Towards Convenience
For those accustomed to the Linux environment, using PowerShell in Windows can sometimes feel cumbersome, particularly when it comes to executing commands that require administrative privileges. Traditionally, this has meant navigating through the start menu and selecting “Run as administrator,” a method that lacks the elegance many users desire.
In contrast, Linux distributions have long embraced the sudo
command, allowing users to prepend “sudo” to any command that necessitates elevated permissions. This simple addition prompts for an administrator password and executes the command seamlessly. Its utility has even inspired a well-known comic from XKCD, highlighting its popularity among users.
Recognizing this need for a more streamlined approach, Microsoft has introduced a feature reminiscent of sudo
in its latest Windows 11 version 24H2, which began rolling out in October 2024. However, it’s important to note that this new feature, also dubbed sudo
, does not function in the same manner as its Linux counterpart, leading to some potential confusion.
To determine if you have access to this feature, navigate to System Settings, then proceed to System > For developers. If you see the option to enable sudo
, you are indeed using the 24H2 version.
The new sudo
feature offers three operational modes. By default, commands will execute in a new window. Alternatively, users can opt for:
- Inline: Executes the command in the same window.
- Input closed: Runs the command in the same window but without accepting input from other commands.
While the official documentation advises maintaining the default setting for security reasons, the Inline option closely mirrors the Linux experience.
Utilizing this feature is straightforward. When you encounter a command that requires administrative access, simply prefix it with sudo
. A pop-up will appear, prompting you to confirm your action.
Upon clicking Yes, the command will execute with the necessary administrative privileges. It’s as simple as that—just prepend sudo
to your commands, and you’re good to go.
Feel free to experiment with your usual commands to gauge your satisfaction with this new functionality. If it doesn’t meet your needs, reverting to the traditional method of opening PowerShell as an administrator remains an option.
There are several reasons why this new sudo
feature might not suit everyone. You may not yet be on the 24H2 version of Windows, or you might encounter compatibility issues with certain applications. Alternatively, if you prefer a quick elevation of your current session, consider using gsudo
. This open-source tool, recommended in Microsoft’s documentation, offers a user experience more akin to the Linux version of sudo
and can be easily installed via the winget package manager.