Posey's Tips & Tricks

Windows 11 Gets the Sudo Command

The inclusion of the Linux staple will make quite a difference when engaging in simple Windows tasks.

Of all the new features that are coming to Windows 11, the one feature that I am most intrigued and excited about is the addition of the Sudo command. When I first heard that Microsoft was adding the Sudo command to Windows, I have to admit that my first reaction was to dismiss the feature as completely unnecessary. In retrospect however, I think that having access to the Sudo command will ultimately prove to be super helpful.

For those who might not be familiar with the Sudo command, it is a staple of the Linux operating system. It tells Linux that you want to run a particular command with root (administrative) privileges. Let me give you an example. In Linux, the command apt-get update is used to update the package index. If you attempt to run this command without using Sudo (just typing apt-get update), the command will usually fail because it lacks the necessary permissions. However, typing Sudo apt-get update will allow the update to be performed because the Sudo command confers the necessary permissions.

Being that the Sudo command essentially instructs the operating system to run a command with administrative privileges, you may be wondering (as I did) why we need such a command in Windows. After all, both PowerShell and the Windows Command Prompt environment allow for elevated sessions in which all commands entered are executed with administrative permissions.

In my mind, the biggest benefit to adding Sudo support to Windows is that it will make command prompt operations just a little bit more convenient. The reason why I say this is because even though I tend to use PowerShell on a daily basis, I don't always give enough forethought to what it is that I am doing. I couldn't tell you how many times I have opened up a PowerShell session and begun a task only to realize that one of the commands that I need to run requires elevated permissions. By that point, I am inevitably eight to ten commands into whatever it was that I am doing. Even so, there is typically no choice but to open an elevated PowerShell session and start all over again.

The new Sudo command will eliminate these types of situations. If you are in the middle of doing something in PowerShell and discover that you need administrative permissions, you don't have to stop what you are doing and open an elevated session. Instead, you will just be able to use the Sudo command and Windows will give you the permissions that you need in order to continue on.

Having the Sudo command at your disposal may also improve security to a degree since there will be less of a need to operate within an elevated session. Instead, the commands that you enter can run under the standard user context unless those commands specifically require administrative credentials.

Interestingly, Microsoft has chosen not to make the Sudo command available by default, perhaps to lessen the chance of it being exploited. If you want to try out the Sudo command, you will first need to install Windows 11 Insider Preview Build 26052. Once you have the necessary Windows version, open Settings and then click on System, followed by For Developers. From there, you will be able to use a toggle bar to enable Sudo.

Another thing that I found interesting about the way that Microsoft is supporting the Sudo command is that there will be three different configuration options. The behavior that I previously described will be known as Inline Sudo. In other words, you can use the Sudo command any time that you want, and it will confer administrative privileges to the command that you are trying to run.

Another option will be to use a mode that Microsoft refers to as Input Closed. When you use Sudo in Input Closed mode, the command that you are executing will be run in a separate process (with elevated permissions). However, that new process will not accept any user input. My understanding is that this will be a more secure way of using the Sudo command, but it probably won't be appropriate for every situation.

The third option will be to run the elevated command in a new window. This option isn't all that different from what we have today with the ability to launch a new elevated PowerShell session on an as needed basis. When you use the Sudo command with the New Window configuration, Windows will open a new console window and run the command within that window.

/ECG/redmondmag/Images/IntroImages2024/OSabstract.

About the Author

Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.

Featured

comments powered by Disqus

Subscribe on YouTube