Wsl
π‘οΈ WSL Cheat-Sheet
This cheat-sheet provides essential commands for managing Windows Subsystem for Linux (WSL), including backing up and restoring distros, symbolic links, file permissions, networking, and running a Linux desktop in WSL2.
π Overview
Product Type: WSL Management Commands
Focus: Key commands for managing WSL distros, symbolic links, networking, and configuring advanced settings.
π§ Key Commands
π Backup and Restore WSL
Listing Running Distros
wsl --list --verbose
Starting/Restarting a Distro
wsl --distribution DISTRO-NAME
Terminate a Running Distro
wsl --t DISTRO-NAME
Terminate All Running Distros and WSL Process
wsl --shutdown
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/.kube ~/.kube
π File Permissions
For advanced settings configuration in WSL, refer to 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 Port Forwarding
$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 Port Forwarding
$port = 8080
netsh interface portproxy delete v4tov4 listenport=$port
netsh advfirewall firewall delete rule name=$port
Show Port Forwardings
netsh interface portproxy show v4tov4
π₯οΈ Linux Desktop in WSL2
With WSL2, itβs possible to install and run a Linux desktop environment (such as XFCE). A tutorial on how to implement this can be found here.
π Resources
π Related
Linux on Windows β Learn more about running Linux on Windows with WSL.
Networking in WSL β Explore more about advanced networking capabilities in WSL.
π Explore More
Advanced WSL Configuration β Deep dive into WSL advanced configuration options.
Setting up WSL for Development β A step-by-step guide to configure WSL for development.
π·οΈ Tags
#wsl
#backup-restore
#symbolic-links
#file-permissions
#networking
#port-forwarding
#linux-desktop
#wsl2