Skip to content

Instantly share code, notes, and snippets.

@djfdyuruiry
Created May 29, 2020 00:20
Show Gist options
  • Save djfdyuruiry/61e32fb69645bd2618182ee17373d068 to your computer and use it in GitHub Desktop.
Save djfdyuruiry/61e32fb69645bd2618182ee17373d068 to your computer and use it in GitHub Desktop.
Ubuntu 20.04 in WSL 2
## change to your username
$user="wsl-user"
# download latest 20.04 release
curl --location `
--remote-name `
"https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-wsl.rootfs.tar.gz"
# import into WSL 2
wsl --import `
"Ubuntu-20.04" `
"C:\ProgramData\Ubuntu2004" `
"focal-server-cloudimg-amd64-wsl.rootfs.tar.gz"
# set as default distro
wsl --set-default "Ubuntu-20.04"
# setup linux user
wsl sh -c "`
addgroup '${user}' \\`
&& adduser --uid '1000' \\`
--ingroup '${user}' \\`
'${user}' \\`
&& usermod --append \\`
--groups 'admin' \\`
'${user}' `
"
# setup default WSL 2 user
Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName `
| Where-Object -Property DistributionName -eq "Ubuntu-20.04" `
| Set-ItemProperty -Name DefaultUid -Value 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment