Windows 11 sudo command

How to enable Sudo on Windows 11

You can now run elevated commands on Windows 11 like on Linux or macOS with "sudo," and here's how to enable the feature.

  • To enable sudo on Windows 11, open Settings > System > For developers, turn on “Enable sudo,” and choose the “Inline” option.
  • You can also open Command Prompt or PowerShell (admin) and run the “sudo config –enable normal” command.

On Windows 11, it’s now possible to enable “sudo,” and in this guide, I will outline the steps to complete this configuration. Starting with the preview build 26052, the operating system adds support for the sudo command for Command Prompt and PowerShell to run elevated commands without having to open the console as an administrator, similar to the command already available in Linux, macOS, and other Unix-based operating systems.

Sudo modes differences

Sudo on Windows 11 offers three modes:

  • Inline: When running the sudo command, the console will allow the execution of administrative tasks within the same window. If you want the same Linux experience, this is the option you have to use.
  • With input disabled: This is the most secure experience. It runs the command in an elevated mode in the current window, but the process won’t have any more inputs. If you need to run additional processes, this mode won’t work.
  • In a new window: When running the sudo command, the Terminal will open a new window as an administrator.

Supported operations

You can perform many operations using this command:

  • Deleting a protected file.
  • Invoking elevated commands.
  • Opening a new terminal to perform any task.

Requirements

The integration of sudo is currently under development, meaning that you will need a device enrolled in the Dev or Canary Channel, and it has to be running Windows 11 build 26052 or higher release. Technically, this feature is expected to roll out as part of the Windows 11 24H2.

In this guide, I will teach you the steps to configure the sudo command on Windows 11. You can also bring the same Linux Sudo experience to version 23H2, 22H2, and Windows 10 with the gsudo tool.

Enable sudo on Windows 11 from Settings

To enable sudo on Windows 11 through the Settings app, use these steps:

  1. Open Settings on Windows 11.

  2. Click on System.

  3. Click the For developers page.

  4. Turn on the Enable sudo toggle switch.

    Windows 11 enable sudo

  5. Click the “Enable sudo” setting.

  6. Choose the “Inline” mode from the “Configure how sudo runs applications” setting for a Linux-like experience.

    Configure how sudo runs apps

Once you complete the steps, you can start using the sudo command on the Windows Terminal whether you use Command Prompt or PowerShell.

Enable sudo on Windows 11 from Terminal

To turn on the sudo command through Command Prompt or PowerShell, use these steps:

  1. Open Start.

  2. Search for Windows Terminal, right-click the top result, and choose the Run as administrator option.

    Quick note: This would be the last time you will need to run the Terminal as admin. You can process the configuration in Command Prompt or PowerShell.
  3. Type the following command to enable sudo “Inline” mode on Windows 11 and press Enter:

    sudo config --enable normal

    Command Prompt enable sudo command

  4. (Optional) Type the following command to enable sudo “In a new window” mode and press Enter:

    sudo config --enable forceNewWindow
  5. (Optional) Type the following command to enable sudo “With input disabled” mode and press Enter:

    sudo config --enable disableInput

After you complete the steps, the sudo command will enable, and you can start using the command to run tools elevated without the need to start a console as an administrator.

Get started using sudo on Windows 11

To use the sudo command, use these steps.

  1. Open Start.

  2. Search for Windows Terminal and click the top result to open the console.

  3. Type the following command to invoke the sudo command help and press Enter:

    sudo -h

    Sudo help command

    Quick note: This command will help you learn how to structure the command, the different arguments, and the available options.
  4. Type the following command to run a command with sudo on Windows 11 and press Enter:

    sudo del mytextfile.txt

    Using sudo command correctly

    Quick note: The command works by appending the sudo prefix before the actual command to elevate the process. The system would still show the “User Account Control” (UAC) dialog to confirm the elevation.

It’s important to note that the sudo command is case-sensitive but only for the available options. For example, sudo -h will bring up the help, but the sudo -H will produce an error.

Microsoft is adding this native support further to bridge the gap between Windows and Unix-like operating systems and make it easier for developers to work in the system with tools they already know.

If you already configured the Windows Terminal to start a command-line session as an administrator, you can still use the Sudo command, but it will make no difference since all the commands will already run elevated. 

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 15 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 21 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me. Email him at [email protected].