How to Enable and Use Sudo for Windows 11

By
Rohit Kumar
Author
Rohit is a certified Microsoft Windows expert with a passion for simplifying technology. With years of hands-on experience and a knack for problem-solving, He is dedicated...
When you purchase through links on our site, we may earn an affiliate commission.

Windows 11 includes a built-in feature called Sudo for Windows that allows users to run commands with administrator privileges from a regular, non-elevated terminal session. It can save time when managing system settings, working with development tools, or performing administrative tasks.

If you have used Linux, you may already be familiar with the sudo command. Windows 11 offers a similar feature, but it works differently from Linux sudo and uses Windows security mechanisms to handle elevated commands.

In this guide, you will learn how to enable Sudo for Windows 11, configure its modes, run commands with administrator privileges, and troubleshoot common problems.

What Is Sudo for Windows 11?

Sudo for Windows is a command-line feature that lets you run supported commands with elevated administrator privileges without opening an entirely separate administrator terminal first.

For example, you can enter a command beginning with sudo in a supported terminal, approve the elevation request, and allow the command to run with the required privileges.

Sudo for Windows is useful for:

  • Running administrative commands from Command Prompt or PowerShell.
  • Managing certain system settings.
  • Working with developer tools and command-line utilities.
  • Performing tasks that require elevated permissions.
  • Reducing the need to repeatedly open a separate administrator terminal.

Important: Windows sudo is not identical to Linux sudo. It uses Windows elevation mechanisms, including User Account Control (UAC), and has its own configuration options and security considerations.

Requirements for Sudo in Windows 11

Before enabling sudo, check that your computer meets the basic requirements.

  • Windows version: Windows 11 version 24H2 or later.
  • Feature availability: Sudo must be available and enabled on your system.
  • Permissions: You may need administrator approval to change the setting.
  • Terminal: Use a supported command-line environment, such as Windows Terminal, Command Prompt, or PowerShell.

To check your Windows version, press Windows + R, type winver, and press Enter.

The About Windows window displays your Windows version and build information. If your computer runs an older release, install available Windows updates and check whether sudo becomes available.

How to Enable Sudo in Windows 11

You can enable Sudo for Windows through the Settings app.

  1. Press Windows + I to open Settings.
  2. Select System from the left sidebar.
  3. Click Advanced or Advanced settings, depending on your Windows 11 version.
  4. Select For developers.
  5. Find the Enable sudo option and switch it to On.
  6. Confirm the change if Windows displays a prompt.

Enable Sudo in System Setting

Select your preferred sudo mode: In a new window, With input disabled, or Inline.

Sudo Mode in Windows 11

Once enabled, sudo is ready to use in a supported terminal.

Note: The exact location or wording of the setting may vary between Windows 11 releases. If you cannot find it, check your Windows version and install available updates.

How to Use Sudo in Windows 11

After enabling sudo, you can use it by typing sudo before a command that requires elevated privileges.

  1. Open Command Prompt, PowerShell, or Windows Terminal normally, without selecting Run as administrator.
  2. Type sudo followed by the command you want to run.
  3. Press Enter.
  4. Review and approve the Windows elevation prompt if it appears.
  5. Allow the command to complete and review its output.

For example, you can enter:

sudo netstat -ab

This runs netstat with elevated privileges, which can provide additional information about network connections and associated executables.

Use sudo only when a command needs administrator privileges. Not every command requires elevation, and elevated commands can make significant changes to your system.

Sudo Modes in Winodws

Windows sudo provides three operating modes. Each mode determines how the elevated process interacts with the terminal.

1. In a New Window

This mode opens the elevated command in a separate window.

Configuration name: forceNewWindow

Advantages include:

  • Keeps the elevated command separate from the original terminal.
  • Provides a straightforward way to run administrative commands.
  • Is a sensible starting option for most users.

For example:

sudo netstat -ab

Depending on the selected configuration, the elevated command runs in a new window.

2. With Input Disabled

This mode runs the elevated command in the current terminal while disabling standard input for the elevated process.

Configuration name: disableInput

This option can be useful when you want command output to remain in the current terminal but do not want the elevated process to receive interactive input through standard input.

Commands that require additional input after they start may not work correctly in this mode.

3. Inline

Inline mode runs the elevated command in the current terminal and allows it to interact with the console.

Configuration name: normal

Advantages include:

  • Keeps command input and output in the current terminal.
  • Can be convenient for interactive command-line tasks.
  • Provides an experience that may feel more familiar to Linux users.

However, inline mode has additional security considerations because the elevated process shares the console with the unelevated process.

Recommendation: For most users, the default In a new window mode is a good starting choice. Use another mode only when your workflow requires it and you understand its implications.

How to Change the Sudo Mode Using Commands

You can change the sudo configuration from an elevated terminal.

Open Windows Terminal, Command Prompt, or PowerShell as an administrator, then run the appropriate command.

Enable In a New Window Mode

sudo config --enable forceNewWindow

Enable With Input Disabled Mode

sudo config --enable disableInput

Enable Inline Mode

sudo config --enable normal

These commands change how sudo launches elevated processes. They do not replace the initial step of enabling sudo through Settings if the feature is currently disabled.

Use the mode that best suits your needs, and avoid switching to inline mode simply because it appears more convenient.

Practical Examples of Using Sudo

The following examples demonstrate how to use sudo with Windows commands and other command-line tools. Run them only when you understand their purpose.

Example 1: Run a Network Diagnostic Command

sudo netstat -ab

The netstat command displays network connection information. Running it with elevated privileges can provide information about the executables associated with network connections.

Example 2: Open the Windows Hosts File

sudo notepad C:\Windows\System32\drivers\etc\hosts

This command attempts to open the Windows hosts file in Notepad with elevated privileges.

The hosts file can affect how domain names are resolved on your computer. Incorrect changes can prevent websites or services from resolving correctly, so edit it only when necessary.

Example 3: Run a Development Command

sudo npm install -g package-name

This example illustrates how sudo can be placed before a development command that requires elevated permissions. Replace package-name with the actual package name.

Not every global package installation requires administrator privileges. Prefer a user-level installation when the tool supports it.

Example 4: Launch DiskPart

sudo diskpart

DiskPart is a Windows disk-management utility that can create, delete, and modify partitions.

Use it with extreme care. Incorrect disk-management commands can cause data loss or make a drive inaccessible.

Always review a command before running it with administrator privileges. Sudo can give the target process access to sensitive system resources.

Sudo for Windows vs. Run as Administrator

Windows sudo and the traditional Run as administrator option both support elevated operations, but they serve slightly different purposes.

FeatureSudo for WindowsRun as administrator
Main purposeElevate a command from a regular terminalStart an application or terminal with elevated permissions
Separate administrator terminal required firstUsually notCommonly used for an elevated terminal session
Uses Windows elevation mechanismsYesYes
Offers different sudo modesYesNo equivalent sudo mode selection
Suitable for an entire elevated application sessionNot its primary purposeYes

Use sudo when you need to elevate a specific command in your current terminal. Use Run as administrator when you want an entire application or terminal session to run with elevated privileges.

How to Disable Sudo in Windows 11

If you no longer need the feature, you can turn it off through Settings.

  1. Press Windows + I to open Settings.
  2. Select System.
  3. Open Advanced or Advanced settings, depending on your Windows version.
  4. Select For developers.
  5. Find Enable sudo and switch it to Off.
  6. Confirm the change if prompted.

After sudo is disabled, you will no longer be able to use the built-in Windows sudo feature until you re-enable it.

Disabling sudo does not remove Windows’ normal administrator options. You can still launch supported applications or terminals using Run as administrator, subject to your account permissions and system policies.

How to Fix Sudo Not Working in Windows 11

If sudo is not recognised, fails to launch, or does not behave as expected, try these troubleshooting methods.

1. Check Your Windows Version

The built-in Windows sudo feature requires Windows 11 version 24H2 or later.

  1. Press Windows + R.
  2. Type winver.
  3. Press Enter.
  4. Check the Windows version displayed.

If your system runs an older release, install available Windows updates and check whether your device supports the required version.

2. Make Sure Sudo Is Enabled

Open Settings → System → Advanced or Advanced settings → For developers.

Find Enable sudo and confirm that it is turned on.

If the option is missing, check your Windows version and install available updates.

3. Check Which Terminal You Are Using

Windows sudo and Linux sudo are different implementations.

If you are running Ubuntu or another Linux distribution through Windows Subsystem for Linux (WSL), its sudo command follows Linux rules and configuration.

Make sure you are using the correct terminal for the command you want to execute.

4. Approve the Elevation Request

Windows may display a User Account Control prompt when you run an elevated command. Review the prompt and approve it only if you trust the command and understand what it does.

If the prompt is blocked by an organization policy or your account lacks the necessary permissions, contact your system administrator.

5. Check the Selected Sudo Mode

Some commands require interactive input. These commands may not behave as expected when sudo is configured with input disabled.

Return to the developer settings and review the selected mode. If necessary, switch to In a new window or another suitable mode.

6. Check Organisation Restrictions

On a work or school computer, an administrator may manage developer settings or prevent users from enabling sudo.

If the setting is unavailable or disabled, contact your IT administrator rather than attempting to bypass organisational security policies.

Sudo for Windows 11 provides a convenient way to run individual commands with administrator privileges without first opening a separate elevated terminal.

To get started, check that your computer runs a supported Windows 11 version, enable sudo through Settings → System → Advanced or Advanced settings → For developers, and select your preferred mode.

For most users, In a new window is a sensible starting option. Use sudo carefully, approve only trusted commands, and limit elevated operations to tasks that genuinely require administrator privileges.

Author
Follow:
Rohit is a certified Microsoft Windows expert with a passion for simplifying technology. With years of hands-on experience and a knack for problem-solving, He is dedicated to helping individuals and businesses make the most of their Windows systems. Whether it's troubleshooting, optimization, or sharing expert insights,