WSL

References

Microsoft Learn - Advanced settings configuration in WSL (opens in a new tab)

Cheatsheet

DNS config

# wsl.conf
[network]
generateResolvConf=false

SSH into different WSL distributions

  • Use different host ports for sshd of different WSL distributions, as all WSL distributions all have the same IP address.

Docker container exits immediately with code 139

  • Add the following content to %USERPROFILE%\.wslconfig and restart WSL
[wsl2]
kernelCommandLine = vsyscall=emulate

Get a list of currently available distributions

wsl --list --online

Install a specified distribution

wsl --install %distribution_name%

Run a specified distribution

wsl -d %distribution_name%

Uninstall a specified distribution

wsl --unregister %distribution_name%

Relocate a distribution

wsl --manage %distribution_name% --move %new_location%

Example:

wsl --manage fedora --move D:\wsl\fedora

Shutdown a distribution

wsl -t %distribution_name%

Shutdown all distributions

wsl --shutdown

Update WSL

wsl --update

Get WSL network mode

wslinfo --networking-mode

Get WSL version

# In WSL distro
wslinfo --wsl-version

Distributions

Fedora