How to List Users in 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:
  1. It is your default user -- it signs-in automatically on launch.
  2. 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.

You can also add users to a WSL distro.

This tutorial will show you how to list the user names of all user accounts in a Windows Subsystem for Linux (WSL) distro in Windows 10.

Here's How:

1. Run the WSL distro (ex: "Ubuntu") you want to see a list of all users for.

2. Copy and paste the command below into the WSL distro console, and press Enter. (see screenshot below)

eval getent passwd {$(awk '/^UID_MIN/ {print $2}' /etc/login.defs)..$(awk '/^UID_MAX/ {print $2}' /etc/login.defs)} | cut -d: -f1

3. After a moment, you will see a list of names for all user accounts in this WSL distro (ex: "Ubuntu").

(Click on image for full size)
List Users in Windows Subsystem for Linux (WSL) Distro in Windows 10-list_users_in_wsl_distro.png

That's it,

Related Tutorials