This tutorial will show you how to log in as root when using Ubuntu on Windows WSL. If you’re new to Linux, this guide makes it simple and easy to follow.
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 have written many tutorials on installing different Linux distributions on Windows WSL.
Why Log In as Root?
Root is the administrator account on Linux. Logging in as root gives you special powers to make critical system changes. However, you should only do this when necessary. Why? Because mistakes made as root can damage your system. That’s why it’s safer to use a regular user account for everyday tasks.
There might be times when you need to install or configure software that requires root access. In those cases, logging in as root can be necessary. Just remember to log back in as a regular user after completing your task.
How to Log In as Root on Ubuntu WSL
Step 1: Close Your Current Ubuntu Session
First, close the Ubuntu console if it’s currently open.
Step 2: Open Windows Command Prompt
Click the Start button and search for “Command Prompt.” Open it when you find it.

Step 3: Run the Configuration Command
In the Command Prompt, type the command below that matches your Ubuntu version. This command tells 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 4: Launch Ubuntu WSL
Open the Ubuntu WSL app. This time you will be logged in as root instead of a regular user.

What Happens When You’re Logged In as Root?
You now have full access to make system changes. The prompt will show a # symbol instead of 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 5: Switch Back to Your Regular User Account
When you’re done with your root tasks, switch back to your regular user account. Open Windows Command Prompt again and type:
⚠️ 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
Logging in as root on Ubuntu WSL should only be done when you need to perform critical system tasks. Use the config --default-user command to switch between root and your regular user account. Always remember to switch back to your regular user account when you’re done with your tasks. This keeps your system safer and more secure. Familiarize yourself with these commands so you can switch users quickly whenever needed.
Frequently Asked Questions
How do I log in as root on Ubuntu WSL?
Is it safe to use the root account on Ubuntu WSL?
What should I do after finishing tasks as root on Ubuntu WSL?
Can I change the default user back to a regular account in Ubuntu WSL?
Why would I need to log in as root on Ubuntu WSL?





Leave a Reply Cancel reply