Skip to content

Instantly share code, notes, and snippets.

@charlesroper
Forked from karthiks/wsl-set-default-user.ps1
Last active February 15, 2021 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlesroper/61e1be1c2240f1a1c7eadd2d4fcccd48 to your computer and use it in GitHub Desktop.
Save charlesroper/61e1be1c2240f1a1c7eadd2d4fcccd48 to your computer and use it in GitHub Desktop.
# Know the id of the username in the original distro that was exported
wsl -d Ubuntu-20.04 -u charlesr -e id -u
# Outputs 1000
# Knowing the id of the username in the distro that was created by importing the tar image
wsl -d UbuntuShropBot -u charlesr -e id -u
# Outputs 1000
# I would want to use this distroname and id, to set this user as the default login profile of WSL.
# I set this up in Windows Registry with the line snippet below:
Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq UbuntuShropBot | Set-ItemProperty -Name DefaultUid -Value 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment