This brief tutorial is going to show students and new users how to login as root when using Ubuntu on Windows WSL environment.
Windows Subsystem for Linux (WSL) is a tool that lets developers run a GNU/Linux environment, including most command-line tools, utilities, and applications directly in Windows without setting up a virtual machine or dual-boot.
You can run full Linux operating systems inside Windows easily. We have written many tutorials on installing different Linux distributions on Windows WSL.
Now that you have Ubuntu installed with WSL, do you know how to logon as a root user? By default, after installing Ubuntu, you’ll be prompted to create a normal user account.
This account will be added to the sudoers file which gives the account sudo permission. However, this is not root.
Now, I don’t think you should login as root on Linux machine. But there might be some cases where you’ll need to login as root to perform some critical tasks.
The day you need to logon as root, then tutorial should come in handy.
Log on as root
As you can see, when you launch the Ubuntu WSL app, it logs directly into the normal user account. See the below screen shot.
The first user after installing is the default account.
Now, to start Ubuntu WSL app and log in as root instead, use the steps below.
First, close the Ubuntu console prompt for the normal user.
Then open Windows command prompt by clicking the start button and finding Commend Prompt or searching for it as shown in the image below.
When the command Prompt opens, type the commands below to configure Ubuntu WSL app to login as root instead of a normal user account.
ubuntu config --default-user root
ubuntu2004 config --default-user root
ubuntu1804 config --default-user root
After running the command above for the respective Ubuntu version, go and start up Ubuntu WSL app and this time the root account should be logged in.
You can see that the root account is logged in.
Now do that you intend to do with the root account. When you’re done, exit.
You need to log back in with the normal account. Simply relaunch Windows Comment Prompt again and run the commands below replacing the root user with the normal account.
ubuntu2004 config --default-user richard
Replace richard with your own account.
There you go.
That should do it!
This post showed you how to logon as root when using Ubuntu on WSL. If you find any error above, please use the comment form below to report.