WSL Cheat-Sheet
Backup and Restore WSL
Listing Running Distros
Starting/Restarting a Distro
| wsl --distribution DISTRO-NAME
|
Terminate a Running Distro
Terminate All Running Distros and WSL process
Backup a WSL Distro
| wsl --export (distribution) (filename.tar)
|
Restore a WSL Distro from Backup
| wsl --import (distribution) (install location) (file location and filename)
|
Symbolic Links
Link .ssh folder
| sudo ln -s /mnt/c/Users/lempa/.ssh ~/.ssh
|
Link .kube folder
| sudo ln -s /mnt/c/Users/lempa/.ssh ~/.ssh
|
File Permissions
Advanced settings configuration in WSL: WSL Config Parameters
Example wsl.conf
| [automount]
enabled = true
options = "metadata,uid=1000,gid=1000,umask=077,fmask=11,case=off"
mountFsTab = true
[interop]
enabled = false
appendWindowsPath = false
|
Networking
Port Forwarding
Find IP Address
| bash.exe -c "ifconfig eth0 | grep 'inet '"
|
Add PortForwarding
| $port = 8080
$remoteaddr = 0.0.0.0
netsh interface portproxy add v4tov4 listenport=$port connectport=$port connectaddress=$remoteaddr
netsh advfirewall firewall add rule name=$port dir=in action=allow protocol=TCP localport=$port
|
Delete PortForwarding
| $port = 8080
netsh interface portproxy delete v4tov4 listenport=$port
netsh advfirewall firewall delete rule name=$port
|
Show PortForwardings
| netsh interface portproxy show v4tov4
|
Linux desktop in WSL2
With WSL2 it's possible to install and run a Linux desktop environment (XFCE). A tutorial on how
to implement that, can be found here.