How to Remove User from Windows Subsystem for Linux (WSL) Distro in Windows 10
The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that enables you to run native Linux command-line tools directly on Windows, alongside your traditional Windows desktop and modern store apps.
When you have Windows Subsystem for Linux (WSL) enabled, you can install WSL distro apps from the Microsoft Store, and export and import WSL distros.
The first time a newly installed WSL distro runs, a Console window will open, and you'll be asked to wait for a minute or two for the installation to complete.
Once installation is complete, you will be prompted to create a new user account (and its password).
Creating your Linux user is the first step in setting up a new Linux distribution on WSL. The first user account you create is automatically configured with a few special attributes:
- It is your default user -- it signs-in automatically on launch.
- It is Linux administrator (a member of the sudo group) by default.
Each Linux distribution running on the Windows Subsystem for Linux has its own Linux user accounts and passwords. You will have to configure a Linux user account any time you add a distribution, reinstall, or reset. Linux user accounts are not only independent per distribution, they are also independent from your Windows 10 user account.
When you add a user to a WSL distro, this new user will not be a member of the sudo (aka: administrator) group by default.
This tutorial will show you how to remove a user from a Windows Subsystem for Linux (WSL) distro in Windows 10.
CONTENTS:
- Option One: Remove User from a WSL Distro while signed in as a Sudu User
- Option Two: Remove User from a WSL Distro while signed in as Root
OPTION ONE
Remove User from a WSL Distro while signed in as a Sudu User
You must be signed in to the WSL distro as a sudo user to do this option.
1. Open the WSL distro (ex: "Ubuntu") you want to remove a
user from.
2. Type the command below into the WSL distro (ex: "Ubuntu") console, and press
Enter. (see screenshot below)
sudo deluser <username>
Substitute <username> in the command above with the actual user (ex: "brink2") you want to remove.
For example: sudo deluser brink2
3. When prompted, enter the
password of the currently signed in
sudo user (ex: "brink"), and press
Enter. (see screenshot below)
This will not be the password of the user (ex: "brink2") you want to remove from this WSL distro.
OPTION TWO
Remove User from a WSL Distro while signed in as Root
1. Open a
command prompt or
PowerShell.
2. Copy and paste the command below into the command prompt or PowerShell for the
WSL distro name (ex: "Ubuntu") you want to remove a
user from, and press
Enter. Leave this command prompt or PowerShell open. (see screenshot below)
This command will change the default user to root for the WSL distro (ex: "Ubuntu").
(Ubuntu)
ubuntu config --default-user root
OR
(openSUSE Leap 42)
openSUSE-42 config --default-user root
OR
(SUSE Linux)
SLES-12 config --default-user root
OR
(Debian)
debian config --default-user root
OR
(Kali Linux)
kali config --default-user root
3. Open the WSL distro (ex: "Ubuntu") you want to remove a
user from.
4. Type the command below into the WSL distro (ex: "Ubuntu") console, and press
Enter. (see screenshot below)
deluser <username>
Substitute <username> in the command above with the actual user (ex: "brink2") you want to remove.
For example: deluser brink2
5. Type the command below into the command prompt or PowerShell from
step 2 for the
user (ex: "brink") you want to be the
default user of this WSL distro (ex: "Ubuntu"), and press
Enter. (see screenshot below)
(Ubuntu)
ubuntu config --default-user <username>
OR
(openSUSE Leap 42)
openSUSE-42 config --default-user <username>
OR
(SUSE Linux)
SLES-12 config --default-user <username>
OR
(Debian)
debian config --default-user <username>
OR
(Kali Linux)
kali config --default-user <username>
Substitute <username> in the command above with the actual user (ex: "brink") you want to be the default user for this WSL distro.
For example: ubuntu config --default-user brink
6. When finished, you can close the WSL distro and command prompt or PowerShell if you like.
That's it,
Shawn