Skip to content

WSL Regular Maintenance (Monthly)

Glad you’re seeing the performance benefits! Here are the essential WSL maintenance commands for your development workflow:

Update package lists and upgrade installed packages

Section titled “Update package lists and upgrade installed packages”
Terminal window
sudo apt update && sudo apt upgrade -y
Terminal window
sudo apt autoremove -y
sudo apt autoclean
Terminal window
npm install -g npm@latest
Terminal window
npm outdated -g
Terminal window
npm update -g
Terminal window
npm cache clean --force

In your project directories, clean node_modules when needed

Section titled “In your project directories, clean node_modules when needed”
Terminal window
rm -rf node_modules && npm install
Terminal window
wsl --update
wsl --shutdown
Terminal window
du -sh ~/projects/*
Terminal window
df -h
Terminal window
nano ~/maintenance.sh

Add this content:

#!/bin/bash

Terminal window
echo "🔄 Updating Ubuntu packages..."
Terminal window
sudo apt update && sudo apt upgrade -y
Terminal window
sudo apt autoremove -y
Terminal window
echo "🔄 Updating npm..."
Terminal window
npm install -g npm@latest
Terminal window
echo "🧹 Cleaning npm cache..."
Terminal window
npm cache clean --force
Terminal window
echo "✅ Maintenance complete!"

Make it executable:

Terminal window
chmod +x ~/maintenance.sh

Run monthly:

Terminal window
~/maintenance.sh

Terminal window
wsl --shutdown

Terminal window
free -h
  • Slow npm installs → Clean cache, restart WSL
  • “Disk full” errors → Clean old node_modules, check du -sh ~/*
  • Git issues → Usually resolved with WSL restart

Most of the time, WSL just works! The monthly system update is really the only must-do maintenance for your development setup.