Tag: WSL Version

  • How to Upgrade WSL from Version 1 to Version 2

    How to Upgrade WSL from Version 1 to Version 2

    This is a post on how to upgrade to WSL 2. The demo below will explain the process of upgrading an installed Windows Subsystem for Linux distribution from running WSL version 1 to WSL version 2.

    WSL has two versions, the latest (WSL 2), and the original version (WSL 1). You can have many different Linux Distributions installed on your machine, and you can easily change the WSL version of one of them.

    My other post, How to Check Installed WSL Versions, will help explain the key and why you might want to perform a WSL upgrade for particular development needs. If you are not going to be using advanced WSL features, then upgrading to WSL 2 is likely a good option for you.

    This is a guide to help upgrade WSL version 2 to WSL version 1. If you are looking to go the other way and downgrade from WSL v2 to WSL v1, see my other post -> How to Downgrade from WSL Version 2 to WSL Version 1

    How to Upgrade from WSL V1 to V2

    To upgrade a WSL distribution from WSL version 1 to version 2, run wsl <distro-name> --set-version 2. You can get the Linux distribution by running wsl -l- v.

    The WSL commands required for this are shared in the example below:

    # check wsl distro versions
    wsl -l -v
    
    # change wsl distro using name above to desired version
    wsl --set-version Debian 2
    WSL Upgrade

    The screenshot above shows us listing the installed WSL distros and setting the WSL version for the Debian instance from WSL 1 to WSL2.

    The WSL Linux distro will be updated immediately to WSL v2.

    To downgrade back to version 1, it’s as simple as changing the number from a 2 to a 1 in the command. As mentioned above in this guide, the following posts may also help provide more info on this:
    How to Check Installed WSL Versions
    How to Downgrade from WSL Version 2 to WSL Version 1

  • How to Downgrade from WSL Version 2 to WSL Version 1

    How to Downgrade from WSL Version 2 to WSL Version 1

    This is a post on how to downgrade from WSL version 2 to WSL 1. The demo below will explain the process of downgrading an installed Windows Subsystem for Linux (WSL) distribution, from WSL2 to WSL1.

    WSL has two versions, the latest WSL v2, and the original version WSL v1. You can have many different Linux distributions installed on your machine, and it’s easy to change the WSL version for one of them.

    My other post, How to Check Installed WSL Versions, will help explain the key and why you might want to perform a WSL upgrade for particular development needs. If you are not going to be using advanced WSL features, then having WSL running on version 2 will be the preferred option.

    If you wish to upgrade WSL from version 1 to version 2, instead of downgrading as we are doing in this post, then see my other post – How to Upgrade WSL from Version 1 to Version 2

    How to Downgrade from WSL 2 to WSL 1

    To downgrade a Windows Subsystem for Linux distribution from WSL 2 to WSL 1, run wsl <distro-name> --set-version 2. You can get the Linux distribution by running wsl -l- v.

    The first command below will check the version of WSL and the following command will set and update the new WSL version.

    # check wsl distro versions
    wsl -l -v
    
    # change wsl distro using name above to desired version
    wsl --set-version Debian 1
    WSL Set Version

    The Debian instance as marked in the screenshot above has now been downgraded from WSL2 to WSL1.

    To upgrade back to version 2, it’s as simple as changing the number from a 1 to a 2 in the command.

    For more WSL Tips, check out my WSL Windows page which has a list of all my WSL blog posts.

  • How to Change Default Linux Distro in WSL

    How to Change Default Linux Distro in WSL

    This post is a guide on how to change a WSL distribution, from your default WSL Linux distro in the Windows Subsystem for Linux This is useful when you are managing multiple WSL distros on your computer.

    List Installed WSL Distros

    First up, we want to display your installed WSL distributions and versions by running the following command.

    # show installed wsl distros & versions
    wsl -l -v
    Get WSL Versions

    The star at the distro name indicates the current default WSL Linux distribution.

    When we enter WSL by running the wsl command, we will log into the Ubuntu-20.04 distro.

    WSL enter Default Distro

    We can run lsb_release -a as above to verify which Linux distribution we are using.

    Set Default WSL Linux Distro

    To set the default WSL Linux distro we need to run wsl -s <wsl-distribution-name>

    Before running this command, the WSL distro name is as-per what is shown in the wsl -l -v command.

    # wsl show versions
    wsl -l -v
    
    # set default wsl distribution (as per 'wsl -l' name)
    wsl -s <wsl-distribution-name>
    wsl default distro

    Noticing here the same ‘lsb_release -a‘ command does not work for me when in the Debian distro – using cat /etc/os-release instead.

    That’s it for this one and is all you should need to know on changing your default WSL distribution. For more WSL Admin tips, check out some of my other WSL Blog posts:
    # How to Reboot WSL (Windows Subsystem for Linux)
    # How to Upgrade WSL from Version 1 to Version 2
    # How to Check WSL Versions

  • How to Check WSL Versions

    How to Check WSL Versions

    To check your installed Windows Subsystem for Linux (WSL) versions, run wsl -l -v. This will show all installed WSL Linux distro names & versions.

    WSL allows users to develop and run applications within a GNU/Linux environment on a Windows computer. Previous to this feature release we needed Virtual Machines (VMs), and dual boot setups were much more common if you wanted local test environments.

    There are 2 versions of WSL, the old (1), and the new (2). We should ideally be using the latest version like all other software in existence, but there are use cases where we might prefer to use WSL Version 1.

    As always, we should look for the most relevant MS Docs when researching a Microsoft Product or Application. The image below shows the current feature differences between WSL 1 and WSL 2.

    wsl1 vs wsl2

    Have a look at Microsoft Documentation – Comparing WSL 1 and WSL 2 for more information on WSL version differences. One of the key differences in 2022 is that WSL 2 allows the use of Docker in WSL.

    How to Check WSL Versions

    To check the versions of your installed WSL distros, open a PowerShell Terminal and run wsl -l -v

    # wsl check version
    wsl -l -v

    The command above lists all installed Windows Subsystem Linux distributions on your local machine, including WSL versions (WSL1 or WSL2) and their state (Running or Stopped).

    wsl check version

    I’m using Windows Terminal in this demo, which is great for managing multiple WSL distributions. We are able to open multiple Linux WSL distros and manage them using tabs as displayed in the screenshot above.

    That concludes this post on how to check a WSL version. Feel free to check out some of my other WSL posts that relate to version checks and the Windows Subsystem:
    # How to Upgrade WSL from Version 1 to Version 2
    # How to Downgrade from WSL Version 2 to WSL Version 1
    # How to Change Default Linux Distro in WSL