Skip to content

WSL default user configuration via wsl.conf

The WSL default user configuration is a setting defined within the /etc/wsl.conf file inside a Linux distribution to specify which user account is automatically logged in when the WSL instance starts^[600-developer-tools-windows-wsl-command.md]. This configuration is typically applied during the initial setup or customization of a WSL environment, such as after importing a custom Linux distribution tar file^[600-developer-tools-windows-wsl-command.md].

Configuration method

To set the default user, a [user] section must be appended to the /etc/wsl.conf file^[600-developer-tools-windows-wsl-command.md]. This is often done using the echo command with append redirection (>>) or by editing the file directly with a text editor.^[600-developer-tools-windows-wsl-command.md]

The specific syntax required is a default key assigned to the target username^[600-developer-tools-windows-wsl-command.md].

Syntax

The configuration entry follows the format below^[600-developer-tools-windows-wsl-command.md]:

[user]
default=<username>

For example, to set the default user to tommy, the command would be^[600-developer-tools-windows-wsl-command.md]:

echo -e "[user]\ndefault=tommy" >> /etc/wsl.conf
  • [[WSL]]
  • [[Linux user management]]

Sources

  • 600-developer-tools-windows-wsl-command.md