Learn to Install Windows Subsystem for Linux (WSL) 2 on Windows in Two Ways: Online and Offline

Windows Subsystem for Linux

Introduction

Windows Subsystem for Linux is a tool that allows developers to run a Linux environment directly on Windows without any modifications, secondary virtual machine software, or dual-boot setups.

WSL 2 is the second version of the Windows Subsystem for Linux, a feature that lets developers run a Linux environment on Windows without needing to change anything, use extra software, or set up dual-booting. WSL 2 improves the way Linux distributions work with Windows by making them faster, more compatible, and easier to switch between. You can choose to run any Linux distribution as WSL 1 or WSL 2, and change it at any time.

WSL 2 is useful because it allows developers to access Linux tools, utilities, and applications on Windows, with better performance, compatibility, and installation. WSL 2 also supports running Docker containers natively, as well as GPU accelerated machine learning and data science workflows. WSL 2 is a great way to enjoy the best of both Windows and Linux on the same machine.

Install WSL 2 Online

The most straightforward method for installing WSL 2 involves obtaining it from the Windows Store through the following steps:

  1. Right-click and select “Run as administrator” to launch PowerShell or Windows Command Prompt in administrator mode.
  2. Enter the command wsl --install and press Enter. This command activates the necessary features for WSL 2 and installs the default Ubuntu version of Linux. If you wish to choose a different default version, you can use the -d flag, for example, wsl --install -d Debian. To view available Linux versions, you can use the command wsl --list --online.
  3. Reboot your computer to complete the installation.
  4. Upon launching a Linux version for the first time, a console window will appear, prompting you to set up your Linux username and password.

Install WSL 2 Offline

Some situations may prevent you from installing WSL Linux distributions using the Microsoft Store. For example, you may be using a Windows Server or Long-Term Servicing (LTSC) desktop OS SKU that does not support Microsoft Store, or your corporate network policies and/or admins may block Microsoft Store usage in your environment. This is the guide for offline installation.

Prerequisites

According to Microsoft, you must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11 to use the commands below.

Enable the Windows Subsystem for Linux

Open PowerShell as Administrator and enter this command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Enable Virtual Machine feature

Open PowerShell as Administrator and enter this command (You can use the same PowerShell above):

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Download the proper Linux kernel update package

In the same PowerShell and enter:

PS C:\TEMP> systeminfo | find "System Type"

Based on the system info, download proper package and run it:

x64 — https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
arm64 — https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_arm64.msi

Download and install the distro(s)

You can download manually the Linux distributions by clicking the following link:

Double click the app bundle and follow the instruction to install the distro step-by-step including setting up user name and password.

Change to WSL version 2

When the distro installation is done, by default the version is set as 1:

C:\>wsl -l -v   
  NAME      STATE           VERSION 
* Ubuntu    Running         1

Type the command (using Ubuntu as an example):

C:\>wsl --set-version Ubuntu 2

C:\>wsl -l -v   
  NAME      STATE           VERSION 
* Ubuntu    Running         2

Bravo!

When all above steps are done, your WSL2 is ready to use. You can find it in the Windows Start Menu

Windows Subsystem for Linux icon shown in the Windows Start Menu

If you have a keen interest in boosting efficiency and fostering innovation in software development, you may explore another article of mine at:

https://medium.com/@dynotes/unlocking-efficiency-and-innovation-containerization-technology-for-digital-government-bd6501b7dbdc

You Might Also Like

Leave a Reply