If you’re like me, you switch between different operating systems. You might have a Linux server for your home experiments and a Windows PC for gaming and everyday tasks. Over time, you get used to certain commands, especially one: sudo.
For years, I’d tap sudo in Windows, only to be met with an error. Although Windows Terminal has seen some great updates, executing commands with elevated privileges was tricky. But good news! With Windows 11, you can now use sudo—you just need to turn it on.
How to Enable sudo on Windows 11
Enabling sudo is simple but not obvious. Here’s how to do it:
- Open Windows Settings and go to the System tab. Click on Advanced.
- Find the Enable sudo slider and turn it on.
Once that’s done, you can choose how sudo runs commands:
- In a new window: This opens a separate terminal.
- With input disabled: Runs in the current window but doesn’t accept new commands.
- Inline: This mimics the Linux experience, letting you see the command’s output in the same window.
You can switch to Inline using this command in an elevated terminal:
bash
sudo config –enable normal
Once enabled, typing sudo in front of a command will give you admin privileges. Keep in mind, you’ll see a UAC prompt each time you use it, asking for permission.
More Than Just a Gimmick
Having sudo on Windows is a game-changer. One of my favorite scenarios is using it with Winget, the package manager. Normally, updating all apps in one go leads to some failures due to permission issues. With sudo, I can run:
bash
sudo winget upgrade –all
I simply click yes on the UAC prompt, and all my apps update automatically.
Another benefit is running other essential commands. Tools like netstat, diskpart, and sfc requiring elevated permissions can now be executed without juggling multiple terminal windows. If I need to edit important files like the Windows hosts file, I can do it easily with:
bash
sudo notepad C:\Windows\System32\drivers\etc\hosts
Understanding the Limitations
However, it’s important to note that sudo on Windows isn’t exactly the same as it is on Linux. When you use sudo, it prompts you through UAC. Unlike Linux where you often have a grace period for credentials after the first use, Windows requires permission every time.
If you’re someone who frequently uses the terminal, consider checking out gsudo, a community tool that mimics sudo but offers features like credential caching.
The Bigger Picture
The inclusion of sudo is symbolic. It shows Microsoft is evolving. They’re beginning to cater to developers and power users who are used to tools like Bash and Zsh. For many everyday users, this might seem trivial, but the ease of executing higher-level commands without hassle is a notable change.
These small updates enhance the user experience significantly. It’s refreshing to see a tech giant like Microsoft adapting to what developers truly need, making tasks less cumbersome on Windows.
For further information, you can check out Microsoft’s official documentation on Windows Terminal or explore community tools like gsudo for an even smoother experience.
