Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

WSL

How to Install Windows Subsystem for Linux

How to Install Windows Subsystem for Linux

Karthick Sudhakar CategoriesLinux DistrosUbuntuWindows Subsystem 3 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.

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.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

Install WSL2 on Windows 10 - Musings on Cloud, Containers, Serverless and DevOps

How to Install WSL 2 on Windows 10 (Updated) - OMG! Ubuntu!

Get started using VS Code with WSL - Microsoft Docs

Set up NodeJS on WSL 2 - Microsoft Docs

Get started using Git on WSL - Microsoft Docs



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: April 25, 2021