How to install Windows Subsystem for Linux

The Windows Subsystem for Linux is a compatibility layer that enables you to run Linux applications natively on Windows 10 and Windows Server 2019. Well done, Microsoft!

You can choose any of the following distributions to run, including Ubuntu 16.04 LTS, Ubuntu 18.04 LTS, OpenSUSE Leap 15, OpenSUSE Leap 42, SUSE Linux Enterprise, Server 12, SUSE Linux Enterprise Server 15, Kali Linux, Debian GNU/Linux, and more.

How do you enable Windows Subsystem for Linux?

You can enable Windows Subsystem for Linux using the Windows Control Panel or use Windows PowerShell. Either of these options will require elevated Administrator permissions. It will also possibly need you to restart your computer.

Control Panel:

Open Control Panel -> Programs and Features -> Turn Windows Feature on or off -> Check Windows Subsystem for Linux

See the following example screenshot:

Enable Windows Subsystem For Linux Via  Windows Control Panel

PowerShell:

Run the following command:

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

See the following example screenshot:

Enable Windows Subsystem For Linux Via  Windows Power Shell

How do you install Windows Subsystem for Linux?

You can do this via the Microsoft App Store or via Windows PowerShell.

App Store:

Open the Microsoft Store and choose your Linux distribution. Find your Linux distribution in the store by searching for: ‘Run Linux on Windows’. 

Microsoft App Store Run Linux On Windows

Alternatively, you can use one of the following popular distributions:

Click the ‘Get’ button once you have decided on the Linux distribution of your choice.

PowerShell:

First, you will need to download your favorite distribution. The following example downloads Ubuntu 18.04:

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing

The Invoke-WebRequest command will download the file to the folder from where you ran the command. In most cases, the default folder will be your user folder.

Next, you need to use the Add-AppxPackage command, which will install your Linux distribution. The following example will install the appx file called Ubuntu.appx from the previous PowerShell step.

Add-AppxPackage .\Ubuntu.appx

The following screenshot shows the steps to install Ubuntu 18.04 in PowerShell:

PowerShell Invoke WebRequest and Add AppxPackage to Enable Windows Subsystem for Linux

How do you run your Linux distribution for the first time?

You should see the Linux distribution you installed as an available app in the Windows start bar.

Open the app and then follow the instructions on the screen. You will be asked to enter your preferred default Linux username. The username does not need to be the same as your Windows user. You will also be asked to enter a password for this user. 

See an example of the process below:

Setup Ubuntu on Windows subsystem for Linux for the first time

You can now run and install all your favorite Linux apps! 

How do you access your local Windows folders?

Use the cd command to go to the ‘/mnt’ folder in Linux. All your drives will be mounted into this folder using 777 permissions. 

The example below shows a computer with both a C: and a D: drive:

Access your local Windows folders in Linux

How do you update your Linux packages?

You may get the following message if you try to install a package:

Package XXX is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source

You can get around this by updating your available Linux packages by running: sudo apt-get update (Ubuntu).

You may also be interested in

About Anto Online

Anto, a seasoned technologist with over two decades of experience, has traversed the tech landscape from Desktop Support Engineer to enterprise application consultant, specializing in AWS serverless technologies. He guides clients in leveraging serverless solutions while passionately exploring cutting-edge cloud concepts beyond his daily work. Anto's dedication to continuous learning, experimentation, and collaboration makes him a true inspiration, igniting others' interest in the transformative power of cloud computing.

View all posts by Anto Online

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.