Sudo command comes to Windows 11

Feb 1, 2024

Windows 11 is getting native support for the Sudo command, similar to sudo in macOS or Linux

One of the most anticipated features of Windows 11 is the native support for the Sudo command, which allows users to execute commands with elevated privileges. Sudo, which stands for “superuser do”, is a common tool in Unix-like operating systems such as macOS and Linux, where it enables users to run programs as another user, typically the administrator or root.

The Sudo command has many benefits for Windows 11 users, such as:

  • Enhanced security: The Sudo command can help prevent malicious programs from gaining unauthorized access to system resources or files. Users can also limit the scope of Sudo command by specifying which commands can be executed with elevated privileges and by whom.
  • Improved productivity: The Sudo command can simplify the workflow of users who need to perform administrative tasks on their Windows 11 devices. Instead of switching to a different account or using a separate terminal, users can simply prefix their commands with Sudo and enter their password when prompted.
  • Increased compatibility: The Sudo command can make it easier for users who are familiar with Unix-like operating systems to transition to Windows 11. Users can use the same syntax and commands that they are used to in macOS or Linux, without having to learn new tools or methods.

How to use the Sudo command in Windows 11

To use Sudo command in Windows 11, users need to enable the Windows Subsystem for Linux (WSL), which is a feature that allows users to run Linux applications and tools on Windows. WSL can be enabled from the Settings app, under Apps > Optional features > Add a feature. Users can then choose from a variety of Linux distributions available in the Microsoft Store, such as Ubuntu, Debian, or Fedora.

Once WSL is enabled and a Linux distribution is installed, users can open a Linux terminal from the Start menu or by typing “wsl” in the Run dialog box. From there, users can use Sudo command as they would in any Unix-like operating system. For example, to update the system packages, users can type:

sudo apt update

To create a new file in the root directory, users can type:

sudo touch /newfile.txt

To edit the file with a text editor such as nano, users can type:

sudo nano /newfile.txt

Users can also use Sudo command to run Windows applications with elevated privileges. For example, to launch Notepad as an administrator, users can type:

sudo /mnt/c/Windows/System32/notepad.exe

Users will be asked to enter their password before executing any Sudo command. The password is the same as the one used for their Windows account. Users can also configure Sudo command to remember their password for a certain period of time or to not require a password at all. However, these options are not recommended for security reasons.

Conclusion

Sudo command is a powerful and versatile tool that can enhance the experience of Windows 11 users who need to perform administrative tasks or who are familiar with Unix-like operating systems. By enabling WSL and installing a Linux distribution, users can access Sudo command from a Linux terminal and use it to run commands with elevated privileges. Sudo command can help improve security, productivity, and compatibility for Windows 11 users.