Windows Finally Has a 'Sudo'-Style Command Too
lifehacker.com
One of the annoying things about using PowerShell in Windows, if you're used to Linux, is having to run it as an admin in order to make system changes. The simplest way to do this is right-clicking the application in the start menu and clicking "Run as administrator," which isn't exactly elegant.It's particularly frustrating because most Linux distributions fixed this a long time ago: the sudo command. Basically, on Linux, if you need to run a single command as an administrator you can just put "sudo" at the beginning and run ityou're asked for an administrator password and the process runs. It's such a useful feature that it even inspired one of the most famous XKCD comics.Someone at Microsoft apparently noticed: sudo is now included in Windows. Sort of. A feature that allows you to run single commands as an administrator, called sudo, is now included in Windows, but this feature is not technically related to the sudo included on Linux systems (Microsoft, as always, is using a confusing name).Anyway: this pseudo-sudo feature is included with Windows 11 version 24H2, released in October 2024 and still rolling out to Windows users as of February 2025. You can check whether you have access to the feature by opening System Settings and heading to System > For developers. Scroll down and you'll see the option to enable sudo (if you don't see the option, you're not using 24H2). Credit: Justin Pot There are three options here regarding how sudo runs. By default, command will run in a new window. There are two more options: Inline, which will run the command in the same window; and Input closed, which runs the command in the same window but without input from other commands in the window. The official documentation heavily recommends leaving the default setting for security reasons, though Inline is much closer to the Linux-style sudo command.Using the feature is straightforward: when running a command that requires administrator privileges, start with sudo. You will see a pop-up asking to confirm. Credit: Justin Pot Click Yes and the command will run as administrator. That's really it: just put sudo at the beginning of your commands to run as administrator. Credit: Justin Pot Try it with your usual commands and see how you like it. If the answer is that you don't, that's fine: go back to opening Powershell as administrator.There are reasons Microsoft's sudo may not work for you. Maybe you're not yet using the 24H2 version of Windows. Maybe you can't get sudo working with the applications you're trying. Or maybe you just want to quickly change your current session into an elevated session. If so, gsudo might work better for you. This open source tool is recommended in Microsoft's documentation as offering features more similar to the Linux version of sudo and can quickly be installed using the winget package manager.
0 Commentaires ·0 Parts ·44 Vue