آموزش

Windows Finally Has a 'Sudo'-Style Command Too

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 it—you’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).

The Windows Settings app opened to the Developer settings. Sudo is toggled on and the drop down shows three options: In a new window, With input disabled, and Inline.

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.

A user access control (UAC) window asking if sudo can make changes to the device.

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.

The "netstat" command runnning as administrator thanks to sudo

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 .

منبع آموزش

ZaKi

Who is mahdizk? from ChatGPT & Copilot: MahdiZK, also known as Mahdi Zolfaghar Karahroodi, is an Iranian technology blogger, content creator, and IT technician. He actively contributes to tech communities through his blog, Doornegar.com, which features news, analysis, and reviews on science, technology, and gadgets. Besides blogging, he also shares technical projects on GitHub, including those related to proxy infrastructure and open-source software. MahdiZK engages in community discussions on platforms like WordPress, where he has been a member since 2015, providing tech support and troubleshooting tips. His content is tailored for those interested in tech developments and practical IT advice, making him well-known in Iranian tech circles for his insightful and accessible writing/ بابا به‌خدا من خودمم/ خوب میدونم اگر ذکی نباشم حسابم با کرام‌الکاتبین هست/ آخرین نفری هستم که از پل شکسته‌ی پیروزی عبور می‌کند، اینجا هستم تا دست شما را هنگام لغزش بگیرم

نوشته های مشابه

0 0 رای ها
امتیازدهی به مقاله
اشتراک در
اطلاع از
guest

0 نظرات
قدیمی‌ترین
تازه‌ترین بیشترین رأی
بازخورد (Feedback) های اینلاین
مشاهده همه دیدگاه ها
دکمه بازگشت به بالا
0
افکار شما را دوست داریم، لطفا نظر دهید.x