WSL2 default user configuration¶
WSL2 default user configuration is the process of defining which user account is automatically logged into when a specific WSL2 distribution instance is launched.^[600-developer-tools-windows-install-multiple-ubuntu-wsl2.md] This step is typically required after manually importing or installing a new instance of a Linux distribution (such as Ubuntu) to ensure it does not default to the root user.
Configuration command¶
To configure the default user for a specific WSL2 distribution, the wsl command is executed with the --user parameter.^[600-developer-tools-windows-install-multiple-ubuntu-wsl2.md] This allows the specification of a username that will be used for the initial login shell.
The general syntax for the command is:
wsl -d <DistroName> -u <Username>
Alternatively, within the context of setting up a new imported instance, you can set the default user for the current session by invoking the executable directly:
<SuiteExecutable>.exe config --default-user <Username>
For example, if using a custom Ubuntu instance, the command might look like Ubuntu-20.04.exe config --default-user <Username>.^[600-developer-tools-windows-install-multiple-ubuntu-wsl2.md]
Workflow context¶
Configuring the default user is a standard step in the workflow of creating Multiple WSL2 instances or manually importing distribution tarballs.^[600-developer-tools-windows-install-multiple-ubuntu-wsl2.md] It follows the creation of user accounts within the Linux environment and precedes the final login verification.
Related Concepts¶
- [[WSL2]]
- [[Multiple Ubuntu WSL2 instances]]
- [[Windows Subsystem for Linux]]
Sources¶
^[600-developer-tools-windows-install-multiple-ubuntu-wsl2.md]