How to Log In as Root on Ubuntu WSL
Logging into root on Ubuntu WSL lets you get full administrator control over your Linux system. This means you can make big changes, like installing special software or changing important system files.
You use the `wsl -d
This level of access is needed for tasks that affect the whole system, like fixing deep problems or setting up advanced features. It’s like having the master key to your Linux world inside Windows.
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) is a tool that lets you run a Linux environment directly in 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. You might need to log in as root WSL to install new programs or change settings that your normal account can’t access, but always remember to switch back to your regular account afterwards to keep your system safe.
Logging in as root allows you to install or configure software requiring root access. This root login is necessary in specific cases. You must log back in as a regular user after completing your task.
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." Opening Command Prompt lets you access advanced system tools.

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
To 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?
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 […]