How to Update and Upgrade WSL Distro Packages in Windows

How to Update and Upgrade WSL Distro Packages in Windows blog banner image

This article details the necessary steps to update and upgrade Windows Subsystem for Linux (WSL) distro packages. WSL allows Windows users to run a Linux environment directly on their machine without needing a virtual machine (VM) or dual-boot setup. It also provides access to popular Linux distributions, such as Ubuntu, Debian, and Kali Linux, allowing users to leverage Linux tools and applications alongside Windows programs.

As you can imagine, keeping WSL Windows distributions updated is crucial. Regular updates provide necessary security patches, bug fixes, and new features that improve stability and compatibility with Windows updates.

Keep your devices secure by knowing how to read update logs.

→ Read this Complete Guide: How to Read Windows Update Logs

Checking installed WSL distributions

Before updating, it’s helpful to check which Linux distributions are installed. To do this, simply open Command Prompt or PowerShell and run the following command:

wsl –list –verbose

This will display all installed distributions, their current versions, and whether they are running WSL 1 or WSL 2. If you need to check the WSL version itself, use:

wsl –version

Difference between WSL 1 and WSL 2

Here is a brief comparison of how WSL 1 and WSL 2 differ:

  • WSL 1 uses a compatibility layer to translate Linux system calls into Windows system calls. It has faster file system access when working with Windows files but lacks full compatibility with Linux applications.
  • WSL 2 runs a real Linux kernel inside a VM, which provides better compatibility and improved support for full system calls. However, it must be noted that file system performance can be slower when accessing Windows files.

🚨 If you want to switch between WSL 1 and WSL 2, you can use the following command:

wsl –set-version <distro_name> 2

And replace <distro_name> with the name of your installed Linux application.

How to update and upgrade WSL distro packages

Method 1: Updating packages in Ubuntu/Debian-based distros

  1. Open WSL by launching your preferred Linux distribution from the Start menu or by running the command wsl in Command Prompt.
  2. Refresh the package lists by running:

sudo apt update

  1. Upgrade installed packages with:

sudo apt upgrade -y

  1. Perform a full system upgrade to ensure all dependencies are up to date:

sudo apt full-upgrade -y

  1. Remove unnecessary packages to free up space:

sudo apt autoremove -y

Each of these steps ensures that software packages remain secure, up-to-date, and optimized for performance.

Method 2: Updating packages in Arch Linux WSL

To update WSL distro packages in Arch Linux, you would need to run the following command in Command Prompt:

sudo pacman -Syu

Keep in mind that Arch Linux follows a rolling release model. This means that regular updates are necessary to prevent software conflicts.

Method 3: Updating WSL kernel (for WSL 2 users)

Run the following command in an elevated PowerShell window:

wsl –update

After updating, restart WSL by executing:

wsl –shutdown

This ensures that all updates are properly applied.

Upgrading WSL distro packages to a new release version

For Ubuntu-based distributions, you can easily upgrade to the latest release by executing:

sudo do-release-upgrade

This command upgrades your system to the newest available version. If you prefer the long-term support (LTS) version, we recommend upgrading only when necessary for stability.

For more information, it’s a good idea to refer to the official documentation for Window WSL Ubuntu20.04.

Troubleshooting common issues

  1. WSL update commands not working: This is when WSL commands produce errors when trying to update.
    • How to resolve it: Ensure WSL is enabled by running wsl –list –verbose and reinstall WSL if necessary.
  1. Package upgrade errors: This is when updates fail due to missing or broken dependencies.
    • How to resolve it:  Run sudo apt –fix-broken install to repair missing dependencies.
  1. Slow updates in WSL: This can occur when there are network issues, and updates take too long to complete.
    • How to resolve it: Change to a faster mirror by modifying the package sources.
  1. WSL 1 vs WSL 2 performance concerns: WSL performance is not as expected.
    • How to resolve it: Switch between WSL versions using wsl –set-version based on your needs.
  1. Kernel updates failing in WSL 2: This happens when attempts to update the WSL kernel do not work.
    • How to resolve it:  Run PowerShell as administrator and use wsl –update.
  1. File system errors in WSL: Occur when files inside the Linux filesystem are corrupted or missing.
    • How to resolve it: Back up important data and reinstall the distribution.
  1. WSL disk space is running low: WSL installation is taking up too much space.
    • How to resolve it: Run sudo apt autoremove && sudo apt clean.
  1. Unable to switch WSL versions: Cannot switch between WSL 1 and WSL 2.
    • How to resolve it: Ensure Windows is up to date and install the latest WSL kernel package.

Best practices for maintaining WSL Windows

  1. Regularly update WSL and installed distributions

Regular updates prevent compatibility issues between Windows and Linux. We recommend setting a routine to check for updates using wsl –update and the appropriate manager commands for your distro.

  1. Monitor disk space usage and clean unnecessary files

Over time, WSL accumulates outdated packages, temporary files, and logs that can consume significant disk space. Running sudo apt autoremove && sudo apt clean in Ubuntu-based distros or sudo pacman -Rns $(pacman -Qdtq) in Arch helps remove unnecessary packages.

  1. Backup important Linux configurations and data

Prevent data loss by regularly backing up configuration files, databases, and important scripts using tools like rsync, tar, or cloud storage solutions. Creating a backup plan prevents disruptions when reinstalling or migrating WSL distributions.

🚨 Check out this guide, Linux Log Management: Advanced Techniques and Best Practices for more information. 

  1. Use WSL 2 for better performance and compatibility

WSL 2 offers improved performance by running a full Linux kernel inside a lightweight virtual machine. It provides better compatibility with Linux applications and networking tools. If you need higher performance and full system call support, use wsl –set-version <distro_name> 2 to switch to WSL 2.

  1. Choose the right distribution for your needs

Different Linux distributions serve different purposes. Ubuntu is great for general use, while Kali Linux is ideal for security testing. Arch Linux offers cutting-edge updates, but it requires more hands-on maintenance. Selecting the right distro helps avoid unnecessary troubleshooting and ensures a smoother workflow.

  1. Limit unnecessary background processes

Use systemctl list-units –type=service to check active services and disable any that aren’t needed. This helps ensure that WSL runs efficiently without unnecessary overhead.

  1. Use a separate home directory for WSL and Windows

While WSL allows access to Windows files, storing large amounts of data in the Windows filesystem (/mnt/c/) can slow down performance. For better speed and reliability, keep WSL-specific files inside the Linux home directory (~/).

  1. Automate updates for convenience

Automating updates ensures your system remains up to date without manual intervention. Create a cron job or systemd timer to run update commands periodically.

  1. Learn basic Linux commands for troubleshooting

Even if you’re not a Linux expert, knowing basic commands like lscdgrep, and top can help diagnose issues quickly. Understanding how to check logs (journalctl -xe), monitor system resources (htop), and manage processes (kill or pkill) makes troubleshooting easier.

💡 Check out this guide on the Essential Linux Commands Users Should Know.

Updating or upgrading WSL in Windows

Updating or upgrading WSL in Windows may seem complicated, but following this guide should make the process more straightforward. It’s highly recommended that you keep WSL and Linux distributions updated to ensure security, performance, and seamless integration with Windows.

 Frequently Asked Questions (FAQs)

  1. What does WSL do in Windows?

WSL allows you to run a Linux environment within Windows without needing a separate virtual machine or dual boot setup. It provides access to Linux tools, scripts, and applications while integrating seamlessly with Windows. This is especially useful for developers, sysadmins, and power users who need both Windows and Linux functionality.

  1. Can I install WSL on Windows?

Yes, WSL can be installed on Windows 10 (version 1903 and later) and Windows 11. You can install it by running wsl –install in an elevated Command Prompt or PowerShell window.

  1. What is the disadvantage of WSL?

While WSL is powerful, it has some limitations compared to full Linux installations. WSL 1 has compatibility issues with certain Linux applications, and WSL 2 has slower file access to Windows directories. Additionally, WSL does not support graphical applications natively without additional configurations.

  1. Can my computer run WSL?

Most modern computers can run WSL, but WSL 2 requires additional system requirements, such as virtualization support. You can check if your system supports WSL 2 by running systeminfo in Command Prompt and looking for “Hyper-V Requirements.” If your system meets these requirements, you can use WSL 2 for a better experience.

  1. What are the requirements for WSL?

To run WSL, you need Windows 10 or Windows 11, with the “Windows Subsystem for Linux” feature enabled. For WSL 2, your system must support virtualization (VT-x for Intel or AMD-V for AMD). Additionally, you should have enough disk space for your chosen Linux distribution.

  1. What’s the difference between updating WSL and updating Linux distros?

Updating WSL refers to upgrading the Windows Subsystem for Linux itself, including improvements to the kernel and system integration. Updating a Linux distribution involves upgrading installed software packages within WSL. We recommend updating both to maintain security and compatibility.

  1. How do I check which WSL version I’m running?

You can check your WSL version by running wsl –list –verbose in Command Prompt or PowerShell. This command displays the installed distributions and whether they are using WSL 1 or WSL 2. If you need to check the overall WSL version, use wsl –version.

  1. Can I automate WSL package updates?

Yes, you can automate updates by using cron jobs in Linux or Windows Task Scheduler. For example, you can create a cron job that runs sudo apt update && sudo apt upgrade -y daily. This ensures your packages stay up to date without manual intervention.

  1. Does updating WSL improve performance?

Yes, updating WSL (especially WSL 2) can improve performance by providing a more optimized kernel and better integration with Windows. Regular updates also fix bugs, improve networking, and enhance file system performance, making WSL run more smoothly.

  1. How do I roll back an update if something goes wrong?

If a WSL update causes issues, you can uninstall and reinstall WSL while preserving your Linux distributions. Alternatively, you can switch back to WSL 1 if WSL 2 is causing problems by running wsl –set-version <distro_name> 1.

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service deliver tool. NinjaOne enables IT teams to monitor, manage, secure, and support all their devices, wherever they are, without the need for complex on-premises infrastructure.

Learn more about Ninja Endpoint Management, check out a live tour, or start your free trial of the NinjaOne platform.

You might also like

Ready to simplify the hardest parts of IT?
×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).