Script Valley
Developer Environment Setup (WSL, Terminal, VS Code)
Understanding WSL2 and Why It ExistsLesson 1.5

How to update and maintain your WSL2 installation

wsl --update, wsl --version, Linux package manager apt, apt update vs apt upgrade, keeping kernel current, WSL2 shutdown command

Keeping WSL2 Up to Date

WSL2 update layers diagram

WSL2 has two independent update surfaces: the WSL kernel (managed by Windows/PowerShell) and the Linux packages inside your distro (managed by apt). You need to maintain both.

Updating the WSL kernel

# Run in PowerShell
wsl --update

# Check current WSL version
wsl --version

Microsoft pushes kernel updates through Windows Update, but wsl --update lets you pull them immediately without waiting for a patch cycle.

Updating packages inside Ubuntu

# Run inside your WSL2 terminal
sudo apt update        # refreshes package index
sudo apt upgrade -y    # installs all available upgrades

Run this regularly โ€” at minimum before starting a new project. apt update alone does nothing to your installed software; it only refreshes the list of available versions. apt upgrade is what actually installs updates.

Full shutdown of WSL2

# Shuts down all running distros and the WSL2 VM
wsl --shutdown

WSL2 does not fully shut down when you close the terminal window โ€” it idles in the background. Use wsl --shutdown before updating the kernel or when troubleshooting memory usage. The VM restarts automatically the next time you open a distro.

How to update and maintain your WSL2 installation โ€” Understanding WSL2 and Why It Exists โ€” Developer Environment Setup (WSL, Terminal, VS Code) โ€” Script Valley โ€” Script Valley