WSL

How to Install Windows Subsystem for Linux (WSL2) on Windows 11?

· 5 min read
How to Install Windows Subsystem for Linux (WSL2) on Windows 11?

Steps to install Windows Subsystem for Linux (WSL2) on Windows 10 works for Windows 11 too. But Microsoft made it super simple in Windows 11. Just one command that takes minutes to install a Linux distribution (Ubuntu by default).

If you are curious about other 3 different options that I mentioned in my earlier post, please check the below article. That might be useful if this single command option does not work in your Windows 11 machine for any reason.

How to Install Windows Subsystem for Linux (WSL2) on Windows 10?
Windows Subsystem for Linux (WSL) is an awesome feature of Windows 10. No more VMware or Oracle VirtualBox is required to run Linux on Windows. WSL is faster and less resource consuming, zero or less configuration compared to any other traditional Virtual Machines (VM). Installation and setup of Lin…

Wondering, why do we need WSL?

WSL is faster and less resource consuming, zero or less configuration or management overhead, blazing fast boot times compared to any other traditional Virtual Machines (VMware or Oracle VirtualBox). Installation and setup of Linux Distribution is lightning-fast (in minutes). Because of seamless integration between Windows Host OS and Linux Guest OS, no separate SSH client (e.g. Putty) or SCP client (e.g. WinSCP) is required, graphical Linux apps can be launched. We can run Visual Studio Code within the Windows Subsystem for Linux (WSL) using Remote - WSL extension. Optional Windows Terminal brings multiple Linux distributions or command lines (Windows Command Prompt, Windows PowerShell etc.) all in one window with tons of customizations (color, font, keyboard shortcuts etc.). Docker can run directly inside of WSL2 (a full Linux Kernel built by Microsoft). And this opens endless opportunities for developers. No doubt, it is made for developers.

Prerequisite

We need necessary access to run the command prompt as administrator.

Request Operation requires elevation

Installation

Search "Command Prompt" App and "Run as administrator".

Command Prompt Run as administrator

Run wsl --install and wait for 1-2 mins to magic to happen.

C:\WINDOWS\system32>wsl --install
Installing: Virtual Machine Platform
Virtual Machine Platform has been installed.

Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.

Downloading: WSL Kernel
Installing: WSL Kernel
WSL Kernel has been installed.

Downloading: GUI App Support
Installing: GUI App Support
GUI App Support has been installed.

The requested operation is successful. Changes will not be effective until the system is rebooted.

Above single command will do all the heavy liftings

  • Install Virtual Machine Platform
  • Install Windows Subsystem for Linux
  • Download WSL Kernel
  • Install WSL Kernel
  • Download GUI App Support
  • InstallGUI App Support

Once the wsl --install executes successfully, we need to restart the system because "Changes will not be effective until the system is rebooted."

Verification

Once restarted, you will be asked to create Unix username and New password.

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: abhijit
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Aug 30 20:25:09 EDT 2022

  System load:  0.25               Processes:             8
  Usage of /:   0.4% of 250.98GB   Users logged in:       0
  Memory usage: 3%                 IPv4 address for eth0: 172.18.171.3
  Swap usage:   0%

0 updates can be installed immediately.
0 of these updates are security updates.


The list of available updates is more than a week old.
To check for new updates run: sudo apt update


This message is shown once once a day. To disable it please create the
/home/abhijit/.hushlogin file.
abhijit@Laptop:~$

Now, your playground is ready!

If you want to set a custom hostname for your playground then please checkout the following post.

How to change hostname on Ubuntu running on Windows WSL?
If you are running Ubuntu on Windows WSL (Windows Subsystem for Linux) and wondering how to change hostname permanently then follow all steps mentioned below. Once hostname is changed, if you get “unable to resolve host <hostname>: Name or service not known” then follow the step #4 for the fix. V…

Note:
Ubuntu gets installed by default. But you can select from a list of valid distributions and install using wsl --install -d <Distro> command.

C:\WINDOWS\system32>wsl -l -o
The following is a list of valid distributions that can be installed.
The default distribution is denoted by '*'.
Install using 'wsl --install -d <Distro>'.

  NAME            FRIENDLY NAME
* Ubuntu          Ubuntu
  Debian          Debian GNU/Linux
  kali-linux      Kali Linux Rolling
  openSUSE-42     openSUSE Leap 42
  SLES-12         SUSE Linux Enterprise Server v12
  Ubuntu-16.04    Ubuntu 16.04 LTS
  Ubuntu-18.04    Ubuntu 18.04 LTS
  Ubuntu-20.04    Ubuntu 20.04 LTS

Troubleshooting

By any chance, if you encounter below error ("WslRegisterDistribution failed with error: 0x800701bc"), then download and update the WSL2 Linux Kernel based on your system type (Run systeminfo | find "System Type" in Windows Command Prompt to find your system type).

WslRegisterDistribution failed with error: 0x800701bc
C:\Users\Abhijit>systeminfo | find "System Type"
System Type:               x64-based PC

Please let me know in the comment section below what do you most like about WSL? Thanks.

References