Learn Linux with WSL: A Practical Starter for Windows Users
Halloo, it’s me SuiiKawaii again - nice to meet ya in another post of the Linux series with pure pain suffer and also joy!!. Today we’re going to make Linux feel at home on Windows by setting up WSL2, then build a practical day-to-day workflow with VS Code, Git, Docker, and a few security-minded tips. If you’re a Windows user learning Linux, this is the fastest safe path.
Before we start you might want to watch this video from the GOAT NetworkChuck:
Table of Contents
- 1) What WSL Is (and WSL1 vs WSL2)
- 2) Prerequisites
- 3) Install WSL2 (3 paths)
- 4) Daily Workflow (the right way)
- 5) Windows ↔ Linux Interop
- 6) Networking in WSL2
- 7) When NOT to Use WSL
- 8) Quick Commands Cheat Sheet
- 9) Troubleshooting & FAQ
- 10) Resources
- Appendix A: Optional .wslconfig & wsl.conf
- Appendix C: Windows Terminal Profiles (ready-to-paste)
- Appendix D: Docker + GPU (CUDA/WSLg) on WSL
- Appendix E: VS Code Dev Containers (Node + Python example)
- Appendix F: Automated WSL Backups (PowerShell + Task Scheduler)
- Appendix G: Performance & QoL Tweaks
- Appendix H: Troubleshooting Deep Dive
- Appendix I: Kali on WSL — Quick Kit
- Appendix J: GPU Quick Start Box (NVIDIA/AMD/Intel)
1) What WSL Is (and WSL1 vs WSL2)
WSL lets you run a GNU/Linux environment directly on Windows without dual-boot.
- WSL1 translates Linux syscalls to Windows (compat layer).
- WSL2 runs a real Linux kernel in a lightweight VM → best compatibility and containers.
Topic | WSL1 | WSL2 |
---|---|---|
Architecture | Translation layer (no Linux kernel) | Lightweight VM with a real Linux kernel |
Compatibility | Good CLI coverage | Near-native (cgroups, iptables, namespaces) |
Filesystem I/O | Fast on Windows FS; slower on Linux FS | Fastest on Linux FS (~ ); slower across /mnt/c |
Docker/Containers | Workarounds only | First-class via Docker Desktop (WSL backend) |
Networking | Shared host IP (simple) | NAT by default; modern builds map localhost reliably |
Resource Usage | Lower baseline | Slightly higher (VM) but dynamic |
Best Use | Simple scripting | Dev/security tooling, containers, most learning paths |
2) Prerequisites
- Windows 11 or Windows 10 (21H2/19044+) recommended.
- Virtualization enabled in BIOS/UEFI (Intel VT-x / AMD-V).
- Quick checks:
wsl --status wsl --version
- On older Windows 10 you may need:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
3) Install WSL2 (3 paths)
A) PowerShell (Admin) — the quickest
wsl --install
wsl --list --online
wsl --install -d <DistroName> # e.g. Debian
B) Microsoft Store — GUI route
Install Ubuntu, Debian, Kali, etc.
C) Upgrade existing WSL1 → WSL2
wsl --set-default-version 2
wsl --list --verbose
wsl --set-version <ExistingDistroName> 2
First boot inside Linux
sudo apt update && sudo apt -y upgrade
(Optional) Enable systemd
Create /etc/wsl.conf
:
[boot]
systemd=true
Apply:
wsl --shutdown
wsl
4) Daily Workflow (the right way)
- Work on Linux FS:
mkdir -p ~/projects && cd ~/projects
/mnt/c
is Windows drive (crossing boundaries is slower).
- VS Code Remote – WSL:
code .
Install extensions: Remote - WSL, Python, ESLint, Prettier, Docker, GitHub PRs.
- Git & SSH in WSL:
ssh-keygen -t ed25519 -C "you@example.com"
cat ~/.ssh/id_ed25519.pub
ssh -T git@github.com
- Python via pyenv + venv:
sudo apt -y install build-essential curl git libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev libffi-dev
curl https://pyenv.run | bash
exec $SHELL
pyenv install 3.12.5 && pyenv global 3.12.5
python -m venv .venv && source .venv/bin/activate
- Node via nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
exec $SHELL
nvm install --lts
5) Windows ↔ Linux Interop
- Drives under
/mnt/c
,/mnt/d
, … - Open Explorer from WSL:
explorer.exe .
- Call Windows from WSL:
notepad.exe README.md
powershell.exe -NoLogo -NoProfile -Command "Get-Date"
- Call WSL from Windows:
wsl.exe ls -la ~
- Clipboard:
ls | clip.exe
- Locale:
sudo update-locale LANG=en_US.UTF-8
- (Optional) GUI apps on Windows 11 (WSLg):
sudo apt install -y gedit
gedit &
6) Networking in WSL2
- NAT behind the scenes; localhost mapping works.
- Check IP:
ip a
- Tiny web server:
cd ~/projects
python3 -m http.server 8000
Open http://localhost:8000
in Windows.
Docker Desktop with WSL backend
- Enable WSL 2 based engine.
- Enable per-distro integration.
- Test:
docker version
docker run hello-world
7) When NOT to Use WSL
Use full VM when you need monitor mode/packet injection, USB passthrough, kernel modules, or isolated network labs. See Build a Home Cybersecurity Lab.
8) Quick Commands Cheat Sheet
wsl --list --online
wsl --list --verbose
wsl --install -d Ubuntu
wsl --set-default-version 2
wsl --set-version <Name> 2
wsl --shutdown
wsl --terminate <Name>
wsl --export <Name> C:\backups\wsl\<Name>.tar
wsl --import <New> C:\WSL\<New> C:\backups\wsl\<Name>.tar --version 2
wsl --set-default <Name>
wsl --update
pwd && ls -la
mkdir -p ~/projects && cd ~/projects
sudo apt update && sudo apt -y upgrade
python3 -m venv .venv && source .venv/bin/activate
python3 -m http.server 8000
9) Troubleshooting & FAQ
WSL2 option missing
wsl --update
wsl --set-default-version 2
DNS / network flaky
wsl --shutdown
Optional custom DNS:
# /etc/wsl.conf
[network]
generateResolvConf = false
sudo rm -f /etc/resolv.conf
echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf
Then wsl --shutdown
.
Port not reachable
- Bind to
0.0.0.0
/127.0.0.1
, check Windows Firewall, checkss -tulpn
.
Large disk under %LOCALAPPDATA%
sudo apt clean
wsl --shutdown
- Compact VHDX (Hyper-V tools / Docker Desktop disk utilities).
Reset / default distro
wsl --unregister <Name> # destructive
wsl --set-default <Name>
10) Resources
- WSL official docs: learn.microsoft.com/windows/wsl/
- Setup a WSL dev environment: learn.microsoft.com/windows/wsl/setup/environment
- Config (
wsl.conf
/.wslconfig
): learn.microsoft.com/windows/wsl/wsl-config - VS Code – Remote WSL: code.visualstudio.com/docs/remote/wsl
- VS Code + WSL tutorial: learn.microsoft.com/windows/wsl/tutorials/wsl-vscode
- Docker Desktop WSL2 backend: docs.docker.com/desktop/features/wsl/
- WSLg (Linux GUI apps): learn.microsoft.com/windows/wsl/tutorials/gui-apps
- GitHub – microsoft/WSL: github.com/microsoft/WSL
Further references (videos):
Appendix A: Optional .wslconfig & wsl.conf
Global (%UserProfile%\.wslconfig
)
[wsl2]
memory=6GB
processors=4
localhostForwarding=true
# swap=8GB
# swapfile=C:\\WSL\\wsl-swap.vhdx
Per-distro (/etc/wsl.conf
)
[boot]
systemd=true
[automount]
enabled=true
options="metadata,umask=22,fmask=11"
mountFsTab=true
Apply:
wsl --shutdown
Appendix C: Windows Terminal Profiles (ready-to-paste)
{
"profiles": {
"list": [
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"name": "Ubuntu (WSL)",
"source": "Windows.Terminal.Wsl",
"commandline": "wsl.exe ~ -d Ubuntu",
"startingDirectory": "//wsl$/Ubuntu/home/<your_user>",
"fontFace": "Cascadia Code",
"fontSize": 12,
"useAcrylic": true,
"acrylicOpacity": 0.85,
"hidden": false
}
]
},
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}"
}
Appendix D: Docker + GPU (CUDA/WSLg) on WSL
nvidia-smi || echo "Driver not detected in WSL"
docker run --rm --gpus all nvidia/cuda:12.3.1-base-ubuntu22.04 nvidia-smi
AMD/Intel: check vendor docs (ROCm / oneAPI). GUI with WSLg on Windows 11 works for many apps.
Appendix E: VS Code Dev Containers (Node + Python example)
.devcontainer/devcontainer.json
{
"name": "wsl-sample",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/node:1": { "version": "lts" },
"ghcr.io/devcontainers/features/python:1": { "version": "3.12" }
},
"postCreateCommand": "python -m pip install --upgrade pip && node -v && python -V",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode-remote.remote-containers",
"ms-python.python",
"ms-toolsai.jupyter",
"esbenp.prettier-vscode"
]
}
}
}
Use VS Code → Dev Containers: Reopen in Container.
Appendix F: Automated WSL Backups (PowerShell + Task Scheduler)
backup-wsl.ps1
param([string]$BackupDir = "C:\backups\wsl")
$ts = Get-Date -Format "yyyy-MM-dd"
New-Item -ItemType Directory -Force -Path $BackupDir | Out-Null
$distros = & wsl.exe --list --quiet
foreach ($d in $distros) {
$safe = $d -replace '[^a-zA-Z0-9._-]', '_'
$out = Join-Path $BackupDir "$($ts)-$($safe).tar"
Write-Host "Exporting $d -> $out"
& wsl.exe --terminate "$d" 2>$null
& wsl.exe --export "$d" "$out"
}
Get-ChildItem $BackupDir -File -Filter *.tar |
Where-Object { $_.CreationTime -lt (Get-Date).AddDays(-14) } |
Remove-Item -Force
Task Scheduler → trigger daily, action:
powershell.exe -ExecutionPolicy Bypass -File "C:\scripts\backup-wsl.ps1"
Restore:
wsl --import <NewName> C:\WSL\<NewName> C:\backups\wsl\<DATE>-<Distro>.tar --version 2
Appendix G: Performance & QoL Tweaks
- Limit RAM/CPU/swap via
.wslconfig
. - Keep repos on Linux FS.
- Mount metadata on
/mnt/c
if you need UNIX perms. - Exclude only trusted paths from AV scans (selective).
- Fix time drift after sleep:
wsl --shutdown
Appendix H: Troubleshooting Deep Dive
Name resolution after network change
# /etc/wsl.conf
[network]
generateResolvConf = true
wsl --shutdown
Permission denied on /mnt/c
→ mount with metadata
(Appendix A).
Port conflicts → on Windows:
Get-Process -Id (Get-NetTCPConnection -LocalPort 8000).OwningProcess
In WSL:
ss -tulpn | grep 8000
Distro stuck at boot → wsl --shutdown
, kill hung vmmem
(carefully), last resort wsl --unregister <Name>
and restore from backup.
Appendix I: Kali on WSL — Quick Kit
Install:
wsl --install -d Kali-Linux
Then:
sudo apt update && sudo apt -y full-upgrade
Enable systemd:
[boot]
systemd=true
Apply:
wsl --shutdown
Metapackages:
sudo apt install -y kali-linux-headless
# or
sudo apt install -y kali-linux-default
# or
sudo apt install -y kali-linux-large
Shell & fonts:
sudo apt install -y zsh zsh-autosuggestions zsh-syntax-highlighting
chsh -s "$(which zsh)"
Set dev font (Cascadia Code / Fira Code) in Windows Terminal.
Tools (pick what you need):
sudo apt install -y nmap nikto sqlmap gobuster metasploit-framework \
john hashcat wordlists seclists wireshark tshark feroxbuster \
wapiti ffuf burpsuite
Add capture perms:
sudo usermod -aG wireshark "$USER"
GUI options: WSLg (Win11) or KeX:
sudo apt install -y kali-win-kex
kex --win -s
Known limits under WSL: monitor mode/USB/raw devices → use a VM Build a Home Cybersecurity Lab.
Appendix J: GPU Quick Start Box (NVIDIA/AMD/Intel)
NVIDIA:
nvidia-smi || echo "Driver not detected in WSL"
docker run --rm --gpus all nvidia/cuda:12.3.1-base-ubuntu22.04 nvidia-smi
AMD/Intel: follow ROCm / oneAPI vendor notes. WSLg handles many GUI/OpenGL apps on Windows 11.
Continue your track:
Thanks for reading!
Until next time — Otsumachi!! 💖☄️✨