In this article, we will see how to remove a user account from a WSL Linux distro. You can remove any user account you created in a distro, including your default user account, leaving root as the only user you have.
Advertisеment
The ability to run Linux natively in Windows 10 is provided by the WSL feature. WSL stands for Windows Subsystem for Linux, which initially, was limited to Ubuntu only. Modern versions of WSL allow installing and running multiple Linux distros from Microsoft Store.
After enabling WSL, you can install various Linux versions from the Store. You can use the following links:
and more.
When you start a WSL distro for the first time, it opens a console window with a progress bar. After a moment of waiting, you will be prompted to type a new user account name, and its password. This account will be your default WSL user account that will be used to sign-in automatically every time you run the current distro. Also, it will be included in the 'sudo' group in order to allow it to run commands elevated (as root).
User Accounts in WSL Linux
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 user account, so you can add or remove a Linux user account without changing your Windows credentials.
Sudo is a special user group in Linux. Members of that group are allowed to run commands and apps as a root user (i.e. elevated). The sudo group is available when the sudo package is installed. Besides the group, it provides the sudo command, that should be used to elevated a command or app, e.g. $ sudo vim /etc/default/keyboard
.
To Remove a User from a WSL Linux Distro in Windows 10,
- Run your WSL Linux distro, e.g. Ubuntu.
- Type the following command and hit the Enter key:
sudo userdel <username>
. Type you password to confirm the operation. - If you switched you default user account to root, you can omit the
sudo
portion and run the command directly, i.e.# userdel <username>
. From the root session, you can remove any user account, including the default one. - Replace the
<username>
portion with the user name for the account you want to remove.
Remove the Home Directory Along with the User Account
By default, the home directory for the user account remains untouched, leaving all the files owned by the deleted user account at their place. Here are some useful options of the userdel
command you can use.
- The -r argument will remove the home directory (usually /home/<username>) and all its contents recursively for the user account you want to delete. Example syntax:
$ sudo userdel -r <username>
. If you are sure you no longer need the files owned by the user account you want to remove, you can specify this argument. - The -f argument forces removal of the currently signed in user.
$ sudo userdel -f <username>
.
That's it.
Related articles:
- Add or Remove Sudo Users in WSL Linux in Windows 10
- Remove User From WSL Linux Distro in Windows 10
- Add User to WSL Linux Distro in Windows 10
- Update and Upgrade WSL Linux Distro in Windows 10
- Run WSL Linux Distro as Specific User in Windows 10
- Reset and Unregister WSL Linux Distro in Windows 10
- Reset Password for WSL Linux Distro in Windows 10
- All Ways to Run WSL Linux Distro in Windows 10
- Set Default WSL Linux Distro in Windows 10
- Find Running WSL Linux Distros in Windows 10
- Terminate Running WSL Linux Distro in Windows 10
- Remove Linux from Navigation Pane in Windows 10
- Export and Import WSL Linux Distro in Windows 10
- Access WSL Linux Files from Windows 10
- Enable WSL in Windows 10
- Set Default User for WSL in Windows 10
- Windows 10 Build 18836 Shows WSL/Linux File System in File Explorer
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!
Advertisеment