Skip to content

Instantly share code, notes, and snippets.

@karthiks
Created September 16, 2020 11:46
Show Gist options
  • Select an option

  • Save karthiks/a8c286365df8d8b49c0eb91dccb1e6b4 to your computer and use it in GitHub Desktop.

Select an option

Save karthiks/a8c286365df8d8b49c0eb91dccb1e6b4 to your computer and use it in GitHub Desktop.

Revisions

  1. karthiks created this gist Sep 16, 2020.
    11 changes: 11 additions & 0 deletions wsl-set-default-user.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # Know the id of the username in the original distro that was exported
    wsl -d Ubuntu-20.04 -u kartz -e id -u
    # Outputs 1000

    # Knowing the id of the username in the distro that was created by importing the tar image
    wsl -d Ubuntu-20 -u kartz -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 Ubuntu-20 | Set-ItemProperty -Name DefaultUid -Value 1000