Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Windows 10 / Install Windows Subsystem for Linux (WSL 2) on Windows 10/11

October 25, 2023 LinuxWindows 10Windows 11

Install Windows Subsystem for Linux (WSL 2) on Windows 10/11

Windows Subsystem for Linux (WSL) allows you to run native apps, write scripts, and run bash Linux commands and scripts directly from within Windows without the need for emulators or separate virtual machines. The current version of the environment is WSL 2, which uses the full Linux kernel (version 5.15) and provides full system call compatibility. The WSL Linux kernel image is a lightweight virtual machine that doesn’t require the full Hyper-V role to be installed to run.

Contents:
  • How to Install Windows Subsystem for Linux (WSL2)
  • Installing Linux Distros on Windows (WSL)
  • Basic Commands for WSL on Windows
  • How to Use Windows Subsystem for Linux (WSL)

You can run WSL 2:

  • On Windows 10 1903+, Windows 11, and Windows Server 2022;
  • Hardware virtualization support must be enabled in the computer’s BIOS/UEFI settings: Intel VT (Intel Virtualization Technology) or AMD-V (SVM Mode).

How to Install Windows Subsystem for Linux (WSL2)

WSL is disabled by default on Windows. In the latest versions of Windows 10 and Windows 11, you can install the WSL environment with just a single command:

wsl --install

This command will automatically enable all the necessary Windows features required for WSL, install the Linux kernel update for WSL2, download the Ubuntu distribution (by default), and install it in WSL.

wsl --install windows command

All that remains is for you to restart your computer and your WSL environment is ready for use!

You can install a different Linux distro for WSL. List valid distribution available for WSL:

wsl --list --online

Specify the Linux distribution name you want to install to WSL. For example:

wsl --install -d kali-linux

list available wsl linux images

If virtualization is not enabled in your computer’s BIOS/UEFI, there will be an error message during WSL installation:

Installation failed with error 0x80070003 or error 0x80370102” it means that Bios Level Virtualization is not enabled on your computer.

You can manually install WSL2 on Windows. To do this, you must manually perform all the steps that the wsl –install command performed automatically:

  1. Install WSL and VirtualMachinePlatform features;
  2. Install the WSL 2 kernel;
  3. Download and install the Linux distribution for WSL.

First, install the following optional Windows components

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Install Microsoft-Windows-Subsystem-Linux command

Then you need to restart your computer.

Download and install the WSL2 Linux kernel update package for x64 machines (https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi). You can download the update manually or with PowerShell:

Invoke-WebRequest -Uri https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi -OutFile "$($env:userprofile)\Downloads\wsl_update_x64.msi" -UseBasicParsing
Invoke-Item "$($env:userprofile)\Downloads\wsl_update_x64.msi"
rm "$($env:userprofile)\Downloads\wsl_update_x64.msi"

Install Windows Subsystem for Linux on Windows 10 and 11

Restart your computer and set WSL 2 as the default environment:

wsl --set-default-version 2

set wsl2 as default subsystem

Installing Linux Distros on Windows (WSL)

Once the WSL kernel has been installed on Windows, you will be able to install one or more Linux distros on your computer.

You can install a package with a Linux distribution from the Microsoft Store. The following Linux versions are available for download:

  • Ubuntu
  • Debian
  • Kali Linux
  • OpenSUSE
  • Oracle Linux
  • SUSE Linux Enterprise Server
  • Fedora

Find the Linux version you want in the Store and install it by clicking the Get button.

Install WSL image from Microsoft Store

If you have disabled the Windows Store, and want to install WSL on a Windows Server Core instance, or on an offline computer (disconnected from the Internet), you can use the Invoke-WebRequest PowerShell cmdlet to download the Ubuntu WSL image file:

Invoke-WebRequest https://aka.ms/wslubuntu2204 -OutFile ubuntu-2204.appx –UseBasicParsing

Install the WSL package as a regular APPX application:

Add-AppxPackage .\ubuntu-2204.appx

Once installed, a window will appear asking for a username and password for your Linux distro.

set wsl linux password

A separate app shortcut for starting WSL Linux will appear in the Start menu after installation.

open wsl from windows start menu

Basic Commands for WSL on Windows

Let’s look at the basic commands for managing the Linux kernel and distributions in WSL.

Check the current WSL core version:

wsl --version

check wsl version

You can manually update the WSL kernel:

wsl --update

Rollback to the previous WSL kernel:

wsl --update rollback

List the Linux versions installed:

wsl --list

Get the default Linux distribution:

wsl --status

Change the default Linux distro in WSL:

wsl --setdefault Ubuntu

list installed linux versions in wsl

Run a specific Linux distribution in WSL:

wsl -d kali-linux

Terminate the WSL environment:

wsl --shutdown

You can login to WSL Ubuntu as root and reset its password:
ubuntu config --default-user root
passwd

Restore default user for WSL:
ubuntu config --default-user your_username

Config files can be used to configure parameters for WSL and Linux distros:

  • wsl.conf – a file with settings for a specific Linux distro (located in the /etc directory)
  • .wslconfig – global settings that are common to all WSL distros (located in the user profile folder %UserProfile%)

For example, to limit computer RAM and CPU usage for all Linux distributions in WSL, create the file %UserProfile%\.wslconfig, contains the following config:

[wsl2]
memory=4GB
processors=2

How to Use Windows Subsystem for Linux (WSL)

The Linux distribution that is installed in the WSL is a fully-fledged operating system. It is therefore recommended to update the packages after installation. On Ubuntu, run the command:

$ sudo apt-get update && sudo apt-get upgrade -y

apt update in ubuntu wsl image

The file system of the WSL Linux distribution is stored in the user profile as a VHDX file. For example, Ubuntu’s virtual disk is in %USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState.

wsl ext4 vhdx disk image file

If there is no free space on the system drive, you can move the WSL image file to another disk.

The Linux file system in the WSL is mounted as a shared folder and can be accessed directly from File Explorer.

access wsl file system from windows file explorer

You can also have direct access to WSL files from Windows via a UNC path. For example:

notepad \\wsl$\Ubuntu\sysops\home\mytext.txt

Conversely, WSL will mount local Windows drives to /mnt directory. You can list files on the C: system drive from Linux:

wsl
ls /mnt
ls/mnt/c

run bash commands in wsl

Other examples of running Linux commands from Windows:

dir | wsl grep Sa
wsl ls ‑la > 123.txt
wsl ls ‑la /proc/cpuinfo
wsl ls ‑la "/mnt/c/Program Files"

You can install any package on Linux. For example, install the Midnight Commander file manager:

$ sudo apt-get install mc

Midnight Commander on WSL

You can use the usbipd-win package to access host USB devices from WSL.

The modern version of WSL 2 lets you run any Linux GUI application (X11 and Wayland) from Windows. For example, you can install the GIMP graphics editor in Ubuntu WSL:

$ sudo apt install gimp -y

Now you can start Gimp on Windows using the command:

wsl gimp

3 comments
1
Facebook Twitter Google + Pinterest
previous post
How to Remove RD Session Host from Remote Desktop Services Deployment
next post
Manage VPN Connections with PowerShell in Windows

Related Reading

How to Cancel Windows Update Pending Restart Loop

May 6, 2025

View Windows Update History with PowerShell (CMD)

April 30, 2025

Change BIOS from Legacy to UEFI without Reinstalling...

April 21, 2025

Remove ‘Your License isn’t Genuine’ Banner in MS...

April 21, 2025

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

3 comments

Jason September 20, 2023 - 1:09 pm

I am unable to enable Windows Subsystem for Linux on my machine as get the following error code. “windows could not complete the requested changes. An illegal character was encountered. For multibyte character…

error code =0x80070246”.

Moreover, i am unbale to run sfc /scannow command which gives the following error.
“C:\Windows\system32>sfc /scannow

Beginning system scan. This process will take some time.

Windows Resource Protection could not perform the requested operation.”

Also, i am unable to install some updates too. Error Code = 0x80070246

Reply
serg February 12, 2024 - 2:53 pm

I have an error when trying to install WSL2 on Windows 11 laptop:
WslRegisterDistribution failed with error: 0x80370102
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS

Then i check my bios settings:
get-wmiObject -class Lenovo_BiosSetting -namespace root\wmi | select-object InstanceName, currentsetting
and voila, I found that I missed one setting:
ACPI\PNP0C14\1_48 VirtualizationTechnology,Disable

Reply
srge March 11, 2024 - 1:32 pm

Android app support in Windows 11 will end in March 2025. Windows Subsystem for Android (WSA) and the Amazon App Store will no longer be available for those who already have them installed. From today, the Amazon App Store will no longer be available for download from the Microsoft Store.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fixing ‘The Network Path Was Not Found’ 0x80070035 Error Code on Windows
  • Recovering Files from BitLocker Encrypted Drive
  • Installing an Open Source KMS Server (Vlmcsd) on Linux
  • How to Access VMFS Datastore from Linux, Windows, or ESXi
  • Using iPerf to Test Network Speed and Bandwidth
  • Moving WSL to Another Drive in Windows
  • Monitoring Domain Name Expiration Date with Zabbix
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top