How to set default user, switch user, and remove a user for WSL

WSL or Windows Subsystem for Linux is an essential component of Windows 10 and a boon for the developers who rely on any of the flavors of Linux to get their work done. However, it has always been a problem to manage users once the administrator account has been set up at the startup. In this article, we will be checking out how to set default user, switch user, and remove a user on a Windows Subsystem for Linux distro on Windows 10.

set default user, switch user, and remove a user for WSL

Set default user, switch user, remove a user for WSL

We will be covering the following procedures in this guide:

  1. How to set default user for WSL
  2. How to  switch user for WSL
  3. How to remove a user for WSL.

1] Set default user for WSL

When you open a WSL Distro on your Windows 10 computer, it starts signing you into a particular default user account. You can change this default user if you want. You need to open Command Prompt or Powershell with Administrator level rights.

Change Default user in WSL

Now execute the following commands for the several Linux distros:

Ubuntu: 

ubuntu config --default-user <USERNAME>

Ubuntu 18.04 LTS:

ubuntu1804 config --default-user <USERNAME>

Ubuntu 16.04 LTS:

ubuntu1604 config --default-user <USERNAME>

openSUSE Leap 42:

openSUSE-32 config --default-user <USERNAME>

SUSE Linux:

SLES-12 config --default-user <USERNAME>

Debian: 

debian config --default-user <USERNAME>

Kali Linux:

kali config --default-user <USERNAME>

You can also replace <USERNAME> to ROOT  if you want to set the default user to ROOT.

2] Switch user in WSL

When you open a WSL distro, the command line automatically logs you into the default user we talked b. But if you want to switch user to another user account, it is fairly simple too.

Switch user in WSL

Open the distro’s root location. Type in one of the following commands to switch to a particular user:

su - <USERNAME>

su -l <USERNAME>

su --login <USERNAME>

You will have to replace <USERNAME> with the name of the user account inside the distro that you want to log into.

3] Remove a user in WSL

In this case, there will be two scenarios. One will be where you are logged in as a SUDO user and the other one where you are logged in as ROOT. We will be covering both of these scenarios.

  • When logged in as a SUDO user.
  • When logged in as a ROOT user.

When logged in as a SUDO user:

remove a user in WSL

You need to execute the following command when you are logged in as a SUDO user and want to delete a User account inside the same Linux distro:

sudo deluser <USERNAME>

When logged in as a ROOT user: 

And if you are logged in as ROOT, the method is slightly different. First, you need to refer to the above guide to set a default user. This default user will be the one that you want to remove. Then, you need to execute the following command to delete a user in the same Linux distro:

deluser <USERNAME>

It is worth making sure that the <USERNAME> must be same as the user account you made the default user.

Hope this helped.

Download this VPN to secure all your Windows devices and browse anonymously
Posted by on , in Category Windows with Tags
Ayush has been a Windows enthusiast since the day he got his first PC with Windows 98SE. He is an active Windows Insider since Day 1 and is now a Windows Insider MVP. He has been testing pre-release services on his Windows 10 PC, Lumia, and Android devices.

Leave a Reply

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


1 + 6 =