Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install Windows Subsystem for Linux - DesignLinux

Sep 18 2020
designlinux 0 Comments

The Windows Subsystem for Linux (WSL) runs a GNU/Linux Environment which includes most of the command-line utilities and applications on top of Windows OS. Traditionally there are many ways we can set up Linux OS to work with. Either it can be a dual boot, running through VMWare or VirtualBox, or installing it as our main OS.

Now with Windows Subsystem for Linux, adds a new capability eliminating the overhead of setting up the OS from scratch. It is easy to set up with WSL and Install Linux and get going. To know more about the architecture of WSL refer to “Microsoft Build 2019 – BRK3068”.

Here we will be setting up WSL 2 which is the latest release. WSL 2 is part of Windows 10, version 2004 released in May 2020. WSL 1 used a translation or compatibility layer between Linux and Windows while WSL 2 uses virtual machine technology to allow you to run a real Linux kernel directly on Windows 10.

Comparisons Between WSL 1 and WSL 2

Comparisons Between WSL1 and WSL2
Comparisons Between WSL1 and WSL2

Before Installing WSL 2 you need Windows 10, Version 1903, Build 18362, or higher.

Enable the Windows Subsystem and Virtual Machine for Linux

You must first enable the “Windows Subsystem for Linux” and Virtual Machine Platform optional features before installing any Linux distributions on the Windows system. The WSL 2 uses Virtual Machine technology instead of a translation layer to communicate between Windows and Linux.

Open PowerShell as Administrator and run the following commands to turn on WSL and VM feature and reboot the system once.

Enable Windows Subsystem for Linux

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

Enable Virtual Machine for Linux

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Enable WSL and VM in Windows
Enable WSL and VM in Windows

Install Your Linux Distribution of Choice on Windows

Open the Microsoft Store and select your favorite Linux distribution.

Run Linux on Windows
Run Linux on Windows

For demonstration purposes, we will install Ubuntu, go to Microsoft store, and in the search bar type Ubuntu.

Install Ubuntu on Windows
Install Ubuntu on Windows

Open Ubuntu 20.04 LTS and click Install.

Install Ubuntu 20.04 in Windows
Install Ubuntu 20.04 in Windows

Launching Ubuntu is pretty easy in Windows. Just go to search and type Ubuntu, it will show all the installed versions of Ubuntu.

You can also pin that in the Windows Taskbar or if you are using a new Windows Terminal you can configure in it. Now we will launch Ubuntu 20.04. If you are launching it for the first time it will take some time to set up a few things at the backend then it will prompt us to set username and password.

Running Ubuntu in Windows
Running Ubuntu in Windows

At this stage, you may receive an error to install the kernel component. To fix this error you have to manually download and install WSL2 Linux Kernel.

0x1bc WSL 2 requires an update to its kernel component. 

For information please visit https://aka.ms/wsl2kernel

Now I have configured both 18.04 and 20.04 in the same way as shown in the previous section. Open the shell and type the following command to check the Distribution and Release of your Ubuntu.

lsb_release -a
Check Ubuntu Release Version
Check Ubuntu Release Version

Now we are done with installing Ubuntu on Windows. Within less time we can have a functional distro where we can start installing tools and packages like docker, ansible, git, python, etc. as per our requirement.

Learn Windows Subsystem Commands for Linux Distro

There are few options we can use to launch our Linux Distribution directly from PowerShell or CMD prompt.

1. Type the following command, which will show the list of options we can use along with wsl.

wsl -help

2. Check the installed version of distribution by running the command the following command.

wsl -l
Check Ubuntu Distribution Version
Check Ubuntu Distribution Version

From the output of this command, you can see two versions of Ubuntu is installed and Ubuntu 20.04 is set to be launched as default.

3. Default Distribution (Ubuntu 20.04) can be launched by simply typing.

wsl
Launch Default Linux Distro
Launch Default Linux Distro

4. Change the default Linux distribution by running the command.

wsl -s Ubuntu-18.04
Change Default Linux Distribution
Change Default Linux Distribution

5. Connect to specific distribution with a specific user by running the command.

wsl -d Ubuntu-18.04 -u tecmint
Connect to Linux Distor with User
Connect to Linux Distor with User

6. We can pass a few flags along with the "wsl -l" command to check the status of the distribution.

  • wsl -l --all – List all distributions.
  • wsl -l --running – List only distributions that are currently running.
  • wsl -l --quiet – Only show distribution names.
  • wsl -l --verbose – show detailed information about all distributions.
Check Distribution State
Check Distribution State

7. By running the following command, we can check what WSL version my Linux Distribution is running with.

wsl -l -v
Check WSL Version
Check WSL Version

My Ubuntu 20.04 is running with version WSL 1 since it is configured long back. I can convert that to WSL 2 by running the command.

wsl --set-version Ubuntu-20.04 2

This will take some time to complete and you can see “Conversion Complete” when WSL 1 is converted to WSL 2.

Convert WSL 1 to WSL 2
Convert WSL 1 to WSL 2

When running the --set-version command, open another PowerShell window and run wsl -l -v to check the current state. It will show as “Converting”.

wsl -l -v
Check Converting State
Check Converting State

You can run the following command again to check the current WSL version. Both my Distribution will now be running with WSL2.

wsl -l -v
List WSL Version
List WSL Version

We can also set WSL2 as the default version so when we install new distribution it will run with WSL2. You can set the default version by running.

wsl --set-default-version 2
Set Default WSL Version
Set Default WSL Version

In this article, we have seen how to configure WSL 2 to install Ubuntu Linux on Windows and learned a few command-line options that we can use from PowerShell or cmd prompt.

During Installation, you may encounter different errors which I have not encountered, in that case, the official troubleshooting document will be a good place to start. Also, take a look at the official FAQ section from Microsoft documentation to get more insight about WSL.

Related

Tags: Ubuntu Tips, Windows Subsystem for Linux

How to Run Cron Jobs Every 5, 10 or 15 Minutes

Prev Post

Diff Command in Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 180
  • 605,930

DesignLinux.com © All rights reserved

Go to mobile version