Skip to content
Follow
Ubuntu Linux Windows

How to Log In as Root on Ubuntu WSL

Richard
Written by
Richard
Jun 27, 2021 Updated Sep 15, 2026 3 min read
How to Send and Receive Text Messages on Windows 11
How to Send and Receive Text Messages on Windows 11

Logging in as root on Ubuntu WSL gives you full administrative control over your Linux environment with just one command. The root account acts as the main system administrator, letting you change system files, manage user accounts, and install software without permission limits.

Advertisement

You can start this mode instantly by running the wsl -d <distro> -u root command in your terminal. For example, typing wsl -d Ubuntu -u root opens your Ubuntu distribution with complete system permissions right away.

⚡ Quick Answer

Close your Ubuntu WSL session and open Command Prompt. Run `ubuntu config –default-user root` (or `ubuntu2004` / `ubuntu1804` for specific versions) to set root as the default user. Relaunch Ubuntu WSL to log in as root.

Advertisement

What is Windows Subsystem for Linux (WSL)?

Windows Subsystem for Linux (WSL) runs a native Linux environment (a lightweight operating system layer) directly inside Windows. You get access to command-line tools, utilities, and applications without setting up a virtual machine or dual-boot. We’ve covered many tutorials on installing different Linux distributions on Windows WSL.

Why Log In as Root?

Ubuntu WSL users often need to log in as root WSL to gain full administrative control over the Linux environment. This high-level access lets you install restricted software, fix broken file permissions, and change system settings that standard user accounts cannot touch. You should only use root access when you need to make deep changes, and switch back to your normal user right after to keep your system safe from accidental damage.

Only use this elevated access for specific administrative tasks. Switch back immediately to prevent accidental misconfigurations.

How to Log In as Root on Ubuntu WSL

Step 1Close Your Current Ubuntu Session

First, close the Ubuntu console if it’s currently open.

Advertisement

Step 2Open Windows Command Prompt

You can open Command Prompt by clicking the Start button and searching for "Command Prompt." Command Prompt handles the configuration updates required for the WSL backend.

Windows Command Prompt window ready for WSL commands
windows command prompt

Step 3Run the Configuration Command

In the Command Prompt, type the command below that matches your Ubuntu version. This command will set Ubuntu to log in as root by default.

⚠️ ADMIN REQUIRED

ubuntu config --default-user root

Advertisement

Or for Ubuntu 20.04:

ubuntu2004 config --default-user root

Or for Ubuntu 18.04:

ubuntu1804 config --default-user root

Advertisement
Ubuntu WSL terminal starting with root user access
ubuntu start wsl as root

Step 4Launch Ubuntu WSL

Open the Ubuntu WSL app. You will now be logged in as the root user, which has full control over the system, instead of a regular user account.

Ubuntu WSL console displaying root login prompt
ubuntu root login console

What Happens When You're Logged In as Root?

You now have full access to make system changes. The prompt will change from a '$' symbol to a '#' symbol. This tells you that you're logged in as root. Perform whatever tasks you need to do while logged in as root.

Step 5Switch Back to Your Regular User Account

Switching back to your regular user account after completing admin tasks stops you from making accidental mistakes that can break Ubuntu WSL. Running your Linux distribution as root all the time leaves your system wide open to security risks and typos that wipe out important files. Open PowerShell on Windows and run your distribution's config command with your normal username to restore standard permissions for your next session.

⚠️ ADMIN REQUIRED

Advertisement

ubuntu2004 config --default-user username

Replace username with your actual account name, for example:

ubuntu2004 config --default-user user1

Ubuntu WSL console showing normal user login session
ubuntu normal user login

Now when you launch Ubuntu WSL, you'll be back to your regular user account.

Advertisement

Summary

⚠️WarningTo log in as root on Ubuntu WSL, remember it's for important tasks only, and always switch back to your normal user account afterward.





Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

Advertisement

📚 Related Tutorials

How to Install phpMyAdmin on Windows WSL with Apache
CMS How to Install phpMyAdmin on Windows WSL with Apache
How to Install Windows Subsystem for Linux (WSL) on Windows 11
Ubuntu Linux How to Install Windows Subsystem for Linux (WSL) on Windows 11
How to Install the LEMP Stack on Windows WSL
Windows How to Install the LEMP Stack on Windows WSL
How to Repair or Reset WSL Ubuntu on Windows 11
Windows How to Repair or Reset WSL Ubuntu on Windows 11

9 Comments

  • Why not just use the normal method with the “su” command. Works just fine for me and is a lot easier and faster.

    Reply
    • redhatprincess

      Because that doesn’t work for everyone. I literally tried to do that on a VM that I didn’t personally create and it didn’t work and I was locked out. His instructions helped me be able to access root

      Reply
  • Thanks! I just needed to set up my user in sudoers and now I won’t have to do this anymore. But that first time I had no idea what to do.

    Reply
  • Yeah it does work on nearly everything but for “wget -q0” commands, it won’t work. Those commands will require one to run it as the actual root for the host system.

    Reply
  • you saved my life man, I lost sudoers access using an user. !! it worked

    Reply
  • Thank you. This worked.

    Reply
  • Hi – is there a way to do this on Windows 11? ubuntu and ubuntu2004 does not work in command prompt.

    Reply
  • Thanks

    Reply
  • […] How to login as root on WSL with Linux OS […]

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *