Advertisement

Find User Accounts in WSL Linux in Windows 10

You may have multiple user accounts in a WSL Linux distro. This post explains how to quickly find available user accounts in a WSL console. The method described in the article is suitable for any WSL distro.

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.

Linux Distros Microsoft Store Windows 10

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).

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.

Find Users Accounts in WSL Linux in Windows 10,

  1. Run your WSL Linux distro, e.g. Ubuntu.Windows 10 WSL Run As User 1
  2. To see everything related to the user accounts in the distro, run the command cat /etc/passwd|more. The output includes special accounts used for daemons, apps, and system user accounts. The more command pauses console output after every page for convenient reading.Windows 10 List WSL Users 1
  3. Now, execute the following command: cat /etc/login.defs and note the UID_MIN and UID_MAX values. In most cases, they will be UID_MIN =1000 and UID_MAX 60000. See the note below.Windows 10 List WSL Users 2
  4. To list only regular users that are created manually, run the command cat /etc/passwd|cut -d: -f1,3|awk -F ':' '$2 >= 1000 {print $0}'|awk -F ':' '$2 < 60000 {prin
    t $0}'. Replace 1000 and 60000 with the UID_MIN and UID_MAX values from the step 3.Windows 10 List WSL Users 3

Note: When you create a new user with the useradd command, its UID (unique user identificator) will be automatically selected from the /etc/login.defs file depending on the UID_MIN and UID_MIN values. By selecting values from that range, you will be able to list regular user accounts only.

The cut command extracts values for column #1 and column #3 from the passwd file (delimited with ':'). The awk command filters the output twice for the lower and upper bounds.

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!

Advertisеment

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.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.