The WSL --setdefaultuser flag is Gone
The WSL flag

What was --setdefaultuser?

  • In earlier versions of WSL (especially legacy ones), Microsoft provided commands (or flags) such as lxrun /setdefaultuser <user> to establish which Linux user would be the default when you launch a distro.
  • Later, for Store-installed distros (e.g. Ubuntu from Microsoft Store), the pattern became something like distro.exe config --default-user <username>


What Changed / Why is --setdefaultuser Removed or Deprecated?

  • Legacy Tools Phased Out: The lxrun tool is deprecated. Commands dependent on it (such as /setdefaultuser) are no longer supported in recent builds of Windows/WSL.
  • Uniform Configuration Approach: Microsoft moved toward more consistent and reliable configuration methods. Instead of ad-hoc flags, there is now an emphasis on either distro config commands or configuration files.
  • Imported Distros: Distributions manually installed or imported (via wsl --import) often lack the usual executable wrappers (like ubuntu.exe) that earlier versions used. This makes the older config --default-user or lxrun-style commands non-functional.


What to Use Now

Here are the current, supported methods to set the default user in WSL:

ScenarioMethod
1) Store-installed distroUse <DistributionName> config --default-user <username> from PowerShell or CMD. E.g. ubuntu config --default-user alice.
2) Imported distro or when config command-based method failsInside the Linux distro, edit /etc/wsl.conf (with root privileges) to include:
[user]
default=<username>
Then terminate the distro (wsl --terminate <distro>) or shutdown WSL (wsl --shutdown) for changes to take effect.
3) WSL version ≥ 2.4.10 (later recent builds)Some builds introduced a wsl --manage <distro> --set-default-user <username> command.

Take note: (Scenario 1)
Windows only creates a .exe launcher (like Ubuntu.exe, Ubuntu-24.04.exe) for distributions installed from the Microsoft Store, not for custom imports (wsl –import).

How to Set the Default User using Scenario 2

1) Open your custom distro (it will log you in as root by default):

powershell

wsl -d Ubuntu24.04-Dev2

2) Inside the distro, edit (or create) the WSL config file:

bash

sudo nano /etc/wsl.conf

3) Add these lines:

ini

[user]
default=ice

4) Save and exit (Ctrl+O, Enter, Ctrl+X).

5) Back in PowerShell, shut down WSL completely so the change takes effect:

powershell

wsl --shutdown

6) Start your distro again:

powershell

wsl -d Ubuntu24.04-Dev2

7) You should now be logged in as ice automatically.


What to Watch Out For / Migration Tips

  • Always check whether the user you want to set already exists in the distro; otherwise setting as default will fail.
  • For imported distros, the config or .exe-launcher might not exist. In this case, /etc/wsl.conf is the primary reliable way.
  • After changing default user via config file, terminating the distro or shutting down WSL is required, otherwise the change might not take effect.

By ice

Leave a Reply

Your email address will not be published. Required fields are marked *