WSL Regular Maintenance (Monthly)
Glad you’re seeing the performance benefits! Here are the essential WSL maintenance commands for your development workflow:
Regular Maintenance (Monthly)
Section titled “Regular Maintenance (Monthly)”1. Update Ubuntu System
Section titled “1. Update Ubuntu System”Update package lists and upgrade installed packages
Section titled “Update package lists and upgrade installed packages”
sudo apt update && sudo apt upgrade -y
Clean up unnecessary packages
Section titled “Clean up unnecessary packages”
sudo apt autoremove -ysudo apt autoclean
2. Node.js/npm Updates
Section titled “2. Node.js/npm Updates”Update npm itself
Section titled “Update npm itself”
npm install -g npm@latest
Check for outdated global packages
Section titled “Check for outdated global packages”
npm outdated -g
Update global packages
Section titled “Update global packages”
npm update -g
3. Clean Up Development Files
Section titled “3. Clean Up Development Files”Clean npm cache
Section titled “Clean npm cache”
npm cache clean --force
In your project directories, clean node_modules when needed
Section titled “In your project directories, clean node_modules when needed”(You’ll do this per project as needed)
Section titled “(You’ll do this per project as needed)”
rm -rf node_modules && npm install
Occasional Maintenance (Quarterly)
Section titled “Occasional Maintenance (Quarterly)”4. WSL System Updates
Section titled “4. WSL System Updates”Run this in Windows PowerShell (as admin)
Section titled “Run this in Windows PowerShell (as admin)”
wsl --updatewsl --shutdown
Then restart WSL
Section titled “Then restart WSL”5. Disk Space Check
Section titled “5. Disk Space Check”Check disk usage in your projects
Section titled “Check disk usage in your projects”
du -sh ~/projects/*
Check overall WSL disk usage
Section titled “Check overall WSL disk usage”
df -h
Pro Tips for Your Workflow:
Section titled “Pro Tips for Your Workflow:”Create a Maintenance Script
Section titled “Create a Maintenance Script”Create ~/maintenance.sh
Section titled “Create ~/maintenance.sh”
nano ~/maintenance.sh
Add this content:
#!/bin/bash
echo "🔄 Updating Ubuntu packages..."
sudo apt update && sudo apt upgrade -y
sudo apt autoremove -y
echo "🔄 Updating npm..."
npm install -g npm@latest
echo "🧹 Cleaning npm cache..."
npm cache clean --force
echo "✅ Maintenance complete!"
Make it executable:
chmod +x ~/maintenance.sh
Run monthly:
~/maintenance.sh
Keep WSL Running Efficiently
Section titled “Keep WSL Running Efficiently”If WSL feels slow, restart it:
Section titled “If WSL feels slow, restart it:”In PowerShell:
Section titled “In PowerShell:”
wsl --shutdown
Then reopen your WSL terminal
Section titled “Then reopen your WSL terminal”
Check WSL memory usage:
Section titled “Check WSL memory usage:”
free -h
Warning Signs to Watch For:
Section titled “Warning Signs to Watch For:”- 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.