{"id":1234924,"date":"2025-02-25T16:00:00","date_gmt":"2025-02-25T21:00:00","guid":{"rendered":"https:\/\/www.prime-wow.com\/?p=1234924"},"modified":"2025-02-25T16:00:00","modified_gmt":"2025-02-25T21:00:00","slug":"windows-finally-has-a-sudo-style-command-too","status":"publish","type":"post","link":"https:\/\/www.prime-wow.com\/?p=1234924","title":{"rendered":"Windows Finally Has a &#8216;Sudo&#8217;-Style Command Too"},"content":{"rendered":"<div>\n<p>One of the annoying things about using PowerShell in Windows, if you&#8217;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 &#8220;Run as administrator,&#8221; which isn&#8217;t exactly elegant.<\/p>\n<p>It&#8217;s particularly frustrating because most Linux distributions fixed this a long time ago: the <code>sudo<\/code> command. Basically, on Linux, if you need to run a single command as an administrator you can just put &#8220;sudo&#8221; at the beginning and run it\u2014you&#8217;re asked for an administrator password and the process runs. It&#8217;s such a useful feature that it even inspired <a href=\"https:\/\/xkcd.com\/149\/\" target=\"_blank\" title=\"open in a new window\" rel=\"noopener\">one of the most famous XKCD comics<\/a>.<\/p>\n<p>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).<\/p>\n<p>Anyway: this pseudo-sudo feature is included with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_11%2C_version_24H2\" target=\"_blank\" title=\"open in a new window\" rel=\"noopener\">Windows 11 version 24H2<\/a>, 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 <strong>System Settings<\/strong> and heading to <strong>System<\/strong> &gt; <strong>For developers<\/strong>. Scroll down and you&#8217;ll see the option to enable sudo (if you don&#8217;t see the option, you&#8217;re not using 24H2).<\/p>\n<div class=\"eloquent-imagery-image\">\n<div class=\"flex justify-center\">\n                    <img decoding=\"async\" class=\"border border-gray-100\" src=\"https:\/\/www.prime-wow.com\/wp-content\/uploads\/2025\/02\/images-1.fill_.size_2000x827.v1740510346.png\" alt=\"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.\" width=\"2000\" height=\"827\" loading=\"lazy\" srcset=\"https:\/\/lifehacker.com\/imagery\/articles\/01JMZ80F81BMQE6EBNBKQW2PPE\/images-1.fill.size_800x331.v1740510346.png 800w, https:\/\/lifehacker.com\/imagery\/articles\/01JMZ80F81BMQE6EBNBKQW2PPE\/images-1.fill.size_1400x579.v1740510346.png 1400w, https:\/\/www.prime-wow.com\/wp-content\/uploads\/2025\/02\/images-1.fill_.size_2000x827.v1740510346.png 2000w\" sizes=\"auto, (max-width: 1408px) 100vw, 1408px\">\n            <\/div>\n<div class=\"mt-2\">\n                            <span class=\"mt-2 font-akshar text-sm tracking-wide\"><\/span><br \/>\n                                        <span class=\"text-xs inline-block text-gray-600\">Credit: Justin Pot<\/span>\n                    <\/div>\n<\/p><\/div>\n<p>There are three options here regarding how sudo runs. By default, command will run in a new window. There are two more options: <strong>Inline<\/strong>, which will run the command in the same window; and <strong>Input closed<\/strong>, which runs the command in the same window but without input from other commands in the window. <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/sudo\/\" target=\"_blank\" title=\"open in a new window\" rel=\"noopener\">The official documentation<\/a> heavily recommends leaving the default setting for security reasons, though Inline is much closer to the Linux-style sudo command.<\/p>\n<p>Using the feature is straightforward: when running a command that requires administrator privileges, start with <code>sudo<\/code>. You will see a pop-up asking to confirm.<\/p>\n<div class=\"eloquent-imagery-image\">\n<div class=\"flex justify-center\">\n                    <img decoding=\"async\" class=\"border border-gray-100\" src=\"https:\/\/www.prime-wow.com\/wp-content\/uploads\/2025\/02\/images-2.fill_.size_2000x1276.v1740510346.png\" alt=\"A user access control (UAC) window asking if sudo can make changes to the device.\" width=\"2000\" height=\"1276\" loading=\"lazy\" srcset=\"https:\/\/lifehacker.com\/imagery\/articles\/01JMZ80F81BMQE6EBNBKQW2PPE\/images-2.fill.size_800x510.v1740510346.png 800w, https:\/\/lifehacker.com\/imagery\/articles\/01JMZ80F81BMQE6EBNBKQW2PPE\/images-2.fill.size_1400x893.v1740510346.png 1400w, https:\/\/www.prime-wow.com\/wp-content\/uploads\/2025\/02\/images-2.fill_.size_2000x1276.v1740510346.png 2000w\" sizes=\"auto, (max-width: 1408px) 100vw, 1408px\">\n            <\/div>\n<div class=\"mt-2\">\n                            <span class=\"mt-2 font-akshar text-sm tracking-wide\"><\/span><br \/>\n                                        <span class=\"text-xs inline-block text-gray-600\">Credit: Justin Pot<\/span>\n                    <\/div>\n<\/p><\/div>\n<p>Click <strong>Yes<\/strong> and the command will run as administrator. That&#8217;s really it: just put sudo at the beginning of your commands to run as administrator. <\/p>\n<div class=\"eloquent-imagery-image\">\n<div class=\"flex justify-center\">\n                    <img decoding=\"async\" class=\"border border-gray-100\" src=\"https:\/\/www.prime-wow.com\/wp-content\/uploads\/2025\/02\/images-3.fill_.size_2000x782.v1740510346.png\" alt='The \"netstat\" command runnning as administrator thanks to sudo' width=\"2000\" height=\"782\" loading=\"lazy\" srcset=\"https:\/\/lifehacker.com\/imagery\/articles\/01JMZ80F81BMQE6EBNBKQW2PPE\/images-3.fill.size_800x313.v1740510346.png 800w, https:\/\/lifehacker.com\/imagery\/articles\/01JMZ80F81BMQE6EBNBKQW2PPE\/images-3.fill.size_1400x547.v1740510346.png 1400w, https:\/\/www.prime-wow.com\/wp-content\/uploads\/2025\/02\/images-3.fill_.size_2000x782.v1740510346.png 2000w\" sizes=\"auto, (max-width: 1408px) 100vw, 1408px\">\n            <\/div>\n<div class=\"mt-2\">\n                            <span class=\"mt-2 font-akshar text-sm tracking-wide\"><\/span><br \/>\n                                        <span class=\"text-xs inline-block text-gray-600\">Credit: Justin Pot<\/span>\n                    <\/div>\n<\/p><\/div>\n<p>Try it with your usual commands and see how you like it. If the answer is that you don&#8217;t, that&#8217;s fine: go back to opening Powershell as administrator.<\/p>\n<p>There are reasons Microsoft&#8217;s sudo may not work for you. Maybe you&#8217;re not yet using the 24H2 version of Windows. Maybe you can&#8217;t get sudo working with the applications you&#8217;re trying. Or maybe you just want to quickly change your current session into an elevated session. If so, <a href=\"https:\/\/github.com\/gerardog\/gsudo\" target=\"_blank\" title=\"open in a new window\" rel=\"noopener\">gsudo<\/a> might work better for you. This open source tool is recommended in Microsoft&#8217;s <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/sudo\/\" target=\"_blank\" title=\"open in a new window\" rel=\"noopener\">documentation<\/a> as offering features more similar to the Linux version of sudo and can quickly be installed using the <a href=\"https:\/\/lifehacker.com\/install-all-of-your-apps-at-once-with-windows-10s-new-p-1843586143\" target=\"_blank\">winget package manager<\/a>. <\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the annoying things about using PowerShell in Windows, if you&#8217;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 &hellip; <a href=\"https:\/\/www.prime-wow.com\/?p=1234924\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[91,110],"tags":[],"class_list":["post-1234924","post","type-post","status-publish","format-standard","hentry","category-lifehacker","category-unfiltered-rss"],"_links":{"self":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts\/1234924","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1234924"}],"version-history":[{"count":0,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts\/1234924\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1234924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1234924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1234924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}