How to install and enable Windows Subsystem for Linux (WSL) on Windows 10


Percy Grunwald's Profile Picture

Written by Percy Grunwald

— Last Updated March 11, 2019

Windows Subsystem for Linux (WSL) lets you run a Linux dev environment directly on your Windows 10 machine without the need for a virtual machine. With WSL installed, you’re able to use Linux command line tools like ssh and vim, open source languages like php and python, as well as popular system services like mysql and nginx.

In this post you’ll see how to install and enable WSL, install the Ubuntu 18.04 Linux distribution and run some commands to test out your WSL installation.

How to install and enable Windows Subsystem for Linux (WSL)

To install and enable Windows Subsystem for Linux (WSL) in Windows 10, all you need to do is enable the optional WSL feature via PowerShell.

Run PowerShell as Administrator by searching for PowerShell in the start menu, right-clicking and selecting Run as administrator:

Run PowerShell as Administrator from the start menu of Windows 10

In PowerShell, run the following command to enable WSL:

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

Once the command completes, you will be prompted to restart Windows to complete the installation:

Enable Windows Subsystem for Linux (WSL) via PowerShell in Windows 10

How to install Ubuntu 18.04 for use with WSL

In order to use the features of WSL, you first need to install a Linux distribution. There are multiple ways to download and install a Linux distribution for use with WSL, but the easiest for installing Ubuntu is simply to use the Microsoft Store.

Download and install Ubuntu 18.04 from the Windows Store

First, launch the Microsoft Store from the taskbar:

Launch Microsoft Store from the taskbar in Windows 10

Next, search for “ubuntu” in the search box and click Ubuntu 18.04 LTS in the search results:

Search for Ubuntu 18.04 in the Microsoft Store on Windows 10

Click Get to download and install Ubuntu 18.04 LTS:

Get Ubuntu 18.04 in the Microsoft Store on Windows 10

Initialize the Ubuntu 18.04 instance

Once it has finished installing, click Launch to finalize the installation of Ubuntu 18.04:

Launch Ubuntu 18.04 from the Microsoft Store on Windows 10

Installation will take a few minutes:

Initializing Ubuntu 18.04 in WSL on Windows 10

When the installation is complete, you will need to set up your username and password:

Create a Linux user for Ubuntu 18.04 in WSL on Windows 10

With the username and password set, the installation is complete and you can start using the bash shell right away:

First bash commands on Ubuntu 18.04 in WSL on Windows 10

In the image above, I tested out some common Linux commands to confirm everything worked:

percy@MSEDGEWIN10:~$ ls
percy@MSEDGEWIN10:~$ pwd
/home/percy
percy@MSEDGEWIN10:~$ date
Thu Mar  7 03:58:17 STD 2019
percy@MSEDGEWIN10:~$ vim test_file
percy@MSEDGEWIN10:~$ ls
percy@MSEDGEWIN10:~$ cat test_file
Hello, World!
percy@MSEDGEWIN10:~$ rm test_file
percy@MSEDGEWIN10:~$ ls

How to launch Ubuntu via WSL at a later time

There are 2 ways to launch your Ubuntu bash shell at a later time:

  1. Run Bash.exe
  2. Pin Ubuntu to the start menu taskbar

Launch WSL with Bash.exe

You can launch your Ubuntu bash shell by running Windows’ Bash.exe. You can launch Bash.exe by typing bash into the search bar in the start menu and pressing enter:

Launch Bash.exe for WSL from the start menu/Cortana in Windows 10

Or by running bash in the run dialogue, which you can open by pressing Windows + R:

Launch Bash.exe for WSL from the run command in Windows 10

Both methods will launch a new window with your Ubuntu bash shell:

Bash.exe for WSL in Windows 10

Bash.exe is located at C:\Windows\System32\Bash.exe.

Pin Ubuntu to the start menu taskbar

Another convenient way to access your Ubuntu shell is to pin it to the taskbar. To do this, first open Microsoft Store and go to My Library:

Open your library in the Microsoft Store in Windows 10

Next, click ... to the right of the Ubuntu item in your library and click Pin to start:

Pin Ubuntu to the taskbar from the Microsoft Store in Windows 10

A shortcut icon to Ubuntu will be added to your task bar:

Ubuntu pinned to the taskbar in Windows 10

Clicking the icon will launch your Ubuntu bash shell in a new window:

Ubuntu via WSL launched from the taskbar in Windows 10

Comment & Share