Remove User from WSL Linux in Windows 10

Windows 10 Linux Icon

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.

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:

  1. Ubuntu
  2. openSUSE Leap
  3. SUSE Linux Enterprise Server
  4. Kali Linux for WSL
  5. Debian GNU/Linux

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 distributionreinstall, 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,

  1. Run your WSL Linux distro, e.g. Ubuntu.
  2. Type the following command and hit the Enter key: sudo userdel <username>. Type you password to confirm the operation.
  3. 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.
  4. 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:

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!

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

Leave a Reply

Your email address will not be published.

Exit mobile version
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.