WSL user and root configuration¶
WSL user and root configuration refers to the administration of user accounts and privileges within the Windows Subsystem for Linux (WSL) environment, particularly focusing on modifying the root user, changing passwords, and setting the default login user.
Root password configuration¶
To change the root password, you must first log in as the root user for the specific WSL distribution.^[wsl.md]
This is accomplished via the command line by launching the distribution with the -u root flag^[wsl.md]:
wsl -d <DistributionName> -u root
Once the session has switched to the root user, the standard passwd command is used to update the password^[wsl.md]:
passwd root
Default user configuration¶
The default user account that WSL logs into can be configured by creating or modifying the /etc/wsl.conf file inside the Linux environment^[wsl.md].
To set a specific user (e.g., a variable $myUsername) as the default, the following configuration block must be appended to the file^[wsl.md]:
[user]
default=$myUsername
This configuration ensures that the specified user is logged in automatically when the WSL instance starts, rather than root or another user.
Related concepts¶
- [[WSL]]
- [[Linux permissions]]
Sources¶
^[wsl.md]