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.
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).
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.
Find Users Accounts in WSL Linux in Windows 10,
- Run your WSL Linux distro, e.g. Ubuntu.
- 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. Themore
command pauses console output after every page for convenient reading. - 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. - 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.
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.
- 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: