{"id":9241,"date":"2024-03-01T17:06:27","date_gmt":"2024-03-01T17:06:27","guid":{"rendered":"https:\/\/cheapwindowsvps.com\/blog\/comparing-sudo-for-windows-vs-runas-and-sudo-for-linux\/"},"modified":"2025-01-16T11:16:15","modified_gmt":"2025-01-16T11:16:15","slug":"comparing-sudo-for-windows-vs-runas-and-sudo-for-linux","status":"publish","type":"post","link":"https:\/\/cheapwindowsvps.com\/blog\/comparing-sudo-for-windows-vs-runas-and-sudo-for-linux\/","title":{"rendered":"Comparing Sudo for Windows vs. Runas and Sudo for Linux"},"content":{"rendered":"<p><div>Sudo for Windows has been <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/blogs.windows.com\/windows-insider\/2024\/02\/08\/announcing-windows-11-insider-preview-build-26052-canary-and-dev-channels\/\">available since Build 26052<\/a> and is currently only accessible through the Windows Insiders program as part of preview builds for Windows 11. At this time, it appears that <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.neowin.net\/news\/microsoft-confirms-sudo-is-not-coming-to-windows-server\/\">sudo will not come to Windows Server 2025<\/a>. In this article, I explain how to use sudo in Windows 11 and compare Sudo for Windows with Runas, Gsudo, and Sudo for Linux.<\/div>\n<\/p>\n<p><p>Sudo, short for &#8220;Superuser do,&#8221; is a privilege elevation utility popular on Linux systems. It makes it easy for administrators and developers to quickly switch between admin and non-admin tasks. It can also be used to run commands as another user. Sudo for Windows is Microsoft&#8217;s sudo implementation.<\/p>\n<\/p>\n<p><p>Sudo allows you to prepend sudo to a command to run that command with administrative privileges. You return to a non-privileged prompt after the privileged command returns. This allows you to switch between privilege levels easily.<\/p>\n<\/p>\n<p><h2>Alternatives to Sudo for Windows<\/h2>\n<\/p>\n<p><p>There are three main alternatives for executing commands with administrator privileges:<\/p>\n<\/p>\n<ol>\n<li><strong>Running the shell as Administrator<\/strong>. They can run all admin-level commands within it. However, the downside is the necessity to manage the overhead of switching between different shells to carry out both admin and non-admin tasks.<\/li>\n<li><strong>Utilizing Runas<\/strong>. Runas is a command-line utility in Windows that enables a user to operate specific programs within the target user&#8217;s permissions and environment. However, Runas always demands a password, whereas Sudo can be set up to run without a password for the specific user executing the Sudo command. Sudo can also be tailored to run all commands in a single window, unlike Runas, which initiates a new window for privileged commands. <\/li>\n<li><strong>Use of Gsudo<\/strong>. Gsudo is an external application that imparts Linux\u2019s sudo functionality to Windows. They can execute their commands in a non-privileged shell and utilize gsudo when required to run admin-level commands. The only downside of this approach is that gsudo is a third-party application, and despite being recommended by Microsoft, there are no guarantees or assurances of compatibility with future Windows versions or ongoing support.<\/li>\n<\/ol>\n<p><h2>Enabling Sudo for Windows<\/h2>\n<\/p>\n<p><p>If they wish to enable sudo for windows, they can <a href=\"https:\/\/www.microsoft.com\/en-us\/windowsinsider\/register\" rel=\"nofollow noopener\" target=\"_blank\">register as an insider<\/a> and then <a href=\"https:\/\/support.microsoft.com\/en-us\/windows\/get-the-latest-windows-update-7d20e88c-0568-483a-37bc-c3885390d212\" rel=\"nofollow noopener\" target=\"_blank\">update their system<\/a> to at least Windows 11, build 26052.<\/p>\n<\/p>\n<p><p>To activate Sudo for Windows, navigate to <em>Settings -&gt; System -&gt; For developers<\/em>.<\/p>\n<p>Toggle Enable Sudo <strong>On<\/strong>. Sudo for Windows offers three configurations: <strong>In a new window<\/strong>, <strong>Inline<\/strong>, and <strong>With input disabled<\/strong>.<\/p>\n<p> <a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Enable-Sudo-for-Windows.png\" rel=\"nofollow noopener\" target=\"_blank\"><\/a> <\/p>\n<h2>How to use Sudo for Windows<\/h2>\n<\/p>\n<p><p>To see Sudo in action on Windows, open up a terminal. Three configurations are available: <em>forceNewWindow<\/em>, <em>disableInput,<\/em> and <em>normal<\/em>. In the Settings app, they correspond to <em>In a new window<\/em>, <em>With input disabled<\/em> and <em>Inline<\/em>, respectively.<\/p>\n<\/p>\n<p><h3>ForceNewWindow mode<\/h3>\n<\/p>\n<p><p>Every command run with sudo is executed in an elevated new window in this mode. You can check the currently active mode in the terminal with the <em>sudo config<\/em> command.<\/p>\n<\/p>\n<p><pre>sudo config<\/p><p><\/pre>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Executing-a-command-with-sudo-in-a-new-window.png\" rel=\"nofollow noopener\" target=\"_blank\"><\/a><\/p>\n<p>Executing a command with sudo in a new window<\/p>\n<\/div>\n<p>For example, running the netstat command with sudo opens a new window. Netstat, as shown below, lists all connections (a) with the processes that created them (b).<\/p>\n<pre>sudo netstat -ab<\/p><p><\/pre>\n<p>Before the elevated window opens, you must consent by selecting <strong>Yes <\/strong>at the User Account Control prompt.<\/p>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Sudo-triggers-UAC.png\" rel=\"nofollow noopener\" target=\"_blank\">Sudo triggers UAC<\/a><\/p>\n<p>Sudo triggers UAC<\/p>\n<\/div>\n<p><p>Netstat runs in an elevated window, which closes automatically once execution is complete.<\/p>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Executing-a-command-with-sudo-in-a-new-window.png\" rel=\"nofollow noopener\" target=\"_blank\">Executing a command with sudo in a new window<\/a><\/p>\n<p>Executing a command with sudo in a new window<\/p>\n<\/div>\n<p><h3>Normal mode<\/h3>\n<\/p>\n<p><p>Normal mode runs elevated commands in the same terminal window \u2014 like <em>sudo<\/em> on Linux.<\/p>\n<\/p>\n<p><p>You can manage Sudo\u2019s configuration through its <em>config<\/em> subcommand. The following commands will put Sudo in <em>normal<\/em> mode to run <em>netstat<\/em>.<\/p>\n<\/p>\n<p><pre>sudo sudo config --enable normal<\/p><p>sudo netstat -ab<\/p><p><\/pre>\n<\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Running-sudo-in-normal-mode.png\">Running sudo in normal mode<\/a><\/p>\n<p><p>Running sudo in normal mode<\/p>\n<\/p>\n<p><h3>DisableInput mode<\/h3>\n<p>DisableInput mode is akin to normal mode except for the fact that commands running in this mode are unable to accept user input. In the standard mode, you can initiate a new elevated shell, such as <em>cmd<\/em>, and consequently execute a series of commands with superior privileges. This can be equated with the default <em>sudo<\/em> behavior on Linux.<\/p>\n<p>In the <em>disableInput<\/em> mode, this is unfeasible. This forms a security measure that hinders potentially malevolent code from infusing keystrokes into the elevated console.<\/p>\n<pre>sudo sudo config --enable disableInput<\/p><p>sudo cmd<\/p><p><\/pre>\n<\/p>\n<p><p>The latter command corresponds to <em>sudo su<\/em> on Linux.<\/p>\n<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Running-sudo-in-disableInput-mode.png\" rel=\"nofollow noopener\" target=\"_blank\">Running sudo in disableInput mode<\/a><\/p>\n<p><h2>Sudo for Windows vs. Sudo for Linux<\/h2>\n<\/p>\n<p><p>Sudo for Windows only supports a subset of the features of its Linux counterpart. One key difference is that Sudo for Windows does not support a <em>udoers<\/em> file. The <em>sudoers<\/em> file in Linux is a configuration file that specifies which users or groups can run commands as root or other users through the <em>sudo<\/em> command, providing fine-grained access control.<\/p>\n<\/p>\n<p><p><em>Sudo<\/em> for Linux also enables you to run commands as any user. Sudo for Windows only allows you to run commands as an Administrator.<\/p>\n<h2>Conclusion<\/h2>\n<p>This article gave you a hands-on look at Sudo for Windows, differentiating it from existing solutions. If you have tried the new Windows feature, please share your experience in the comments below.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sudo for Windows has been available since Build 26052 and is currently only accessible through the Windows Insiders program as part of preview builds for Windows 11. At this time, it appears that sudo will not come to Windows Server 2025. In this article, I explain how to use sudo in Windows 11 and compare [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9242,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92,114,119,99],"tags":[],"class_list":["post-9241","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-security","category-windows","category-windows-11"],"_links":{"self":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/comments?post=9241"}],"version-history":[{"count":1,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9241\/revisions"}],"predecessor-version":[{"id":10271,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9241\/revisions\/10271"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media\/9242"}],"wp:attachment":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media?parent=9241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/categories?post=9241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/tags?post=9241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}