How to Log In as Root on Ubuntu WSL
Logging in as root on Ubuntu WSL gives you full administrative control over your Linux environment inside Windows. This root account acts as the master key to your system, letting you change important files and install special software.
You can jump straight into this powerful mode by running the wsl -d <distro> -u root command in your terminal. For example, typing wsl -d Ubuntu -u root opens Ubuntu with complete system permissions.
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.
What is Windows Subsystem for Linux (WSL)?
Windows Subsystem for Linux (WSL) runs a native Linux environment 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?
Logging into root on Ubuntu WSL gives you complete control over your system, akin to being the main boss. Root access is often necessary to install new software or modify restricted system settings. Always switch back to a standard user account afterward to maintain system security.
This elevated access is required only for specific administrative tasks, and switching back immediately afterward prevents accidental system 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.
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.

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
Or for Ubuntu 20.04:
ubuntu2004 config --default-user root
Or for Ubuntu 18.04:
ubuntu1804 config --default-user 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.

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 is very important for keeping your Ubuntu WSL system safe. To switch back, you'll use a command like 'ubuntu2004 config --default-user username', replacing 'username' with your actual login name, ensuring you are logged in as your normal user next time you open WSL.
⚠️ ADMIN REQUIRED
ubuntu2004 config --default-user username
Replace username with your actual account name, for example:
ubuntu2004 config --default-user user1

Now when you launch Ubuntu WSL, you'll be back to your regular user account.
Summary
Was this guide helpful?
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.
Why not just use the normal method with the “su” command. Works just fine for me and is a lot easier and faster.
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
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.
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.
you saved my life man, I lost sudoers access using an user. !! it worked
Thank you. This worked.
Hi – is there a way to do this on Windows 11? ubuntu and ubuntu2004 does not work in command prompt.
Thanks
[…] How to login as root on WSL with Linux OS […]