How to install WSL on Windows 10

Updated: 12/05/2021 by Computer Hope
WSL bash illustration

WSL (Windows Subsystem for Linux), is a free, optional feature of Windows 10 that allows Linux programs to run on Windows. It provides you with a Windows version of the bash shell and a compatibility layer that permits many Linux programs to run natively on your Windows machine.

System requirements

Before installing WSL, make sure your computer meets the minimum system requirements to run WSL:

  • You must be running Windows 10 version 1607 (the Anniversary update) or above.
  • WSL only runs on 64-bit versions of Windows 10. 32-bit versions are not supported.

To check that the computer meet the requirements, follow these steps:

  1. Open your Settings. You can do this by clicking the gear icon on the Start menu, or by opening the Power User Tasks menu and choosing Settings.
  2. In the Settings window, choose System.
  3. On the left side of the System window, choose About.
  4. On the right side of the window, system information is displayed. Make sure the Version is at least 1607, and the System type is a 64-bit operating system.

Windows settings, system, about

If the Version number is less than 1607, you must perform a Windows Update before installing WSL.

If the System type is not a 64-bit operating system, you cannot run WSL.

Installing WSL

To install WSL, follow these steps.

  1. Click Start, type cmd, right-click on Command Prompt and choose the option to run as Administrator.
  2. Once at the command prompt type wsl --install and press Enter.

or

  1. Open a new PowerShell window as Administrator. To do this, open your Start menu, scroll down to W, and expand the Windows PowerShell folder. Right-click Windows PowerShell, choose More, then Run as administrator.
  1. At the PowerShell prompt, run the following command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  1. Some necessary software downloads, and the WSL subsystem will be enabled after you reboot. Linux itself is not installed yet, however (until you choose a Linux distribution, in step 5.)
  1. When the download is complete, PowerShell ask if you're ready to reboot the computer. Before rebooting, make sure any documents are saved, and any open applications are closed. Type Y, or if you're going to reboot later, type N instead.
  1. After your computer reboots, log in to Windows and open a new Command prompt (or PowerShell). At the prompt, run:
bash
  1. Bash will inform you that no distribution is installed, and give you a URL for downloading one from the Windows Store:
Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Windows Store:
https://aka.ms/wslstore
Press any key to continue...
  1. In a web browser, navigate to the URL (Uniform Resource Locator) https://aka.ms/wslstore to download a WSL-integrated Linux distribution. As of this writing, choices are Ubuntu, OpenSUSE, SUSE Enterprise Server, Debian, and Kali. If you're unsure what to pick, we recommend Ubuntu.

In the Microsoft Store, choose Ubuntu.

  1. Click the distribution of your choice, then click Get.

To download Ubuntu from the Microsoft Store, click Get.

  1. When the installation is complete, click Launch. You will see this message:
Installing, this may take a few minutes...

It may silently wait for you to press a key after it's done, so you might want to press Backspace every 15 seconds or so, to check if it's finished.

Note

You may receive this error:

Installing, this may take a few minutes...
Installation failed!
Error: 0x8000000d
Press any key to continue...

This error is a known bug that occurs in some versions of Windows 10. If you get this error, you can fix it by repeating steps 1 and 2. Then, continue to step 10.

  1. Ubuntu is now installed, and WSL is enabled. You can open the WSL Ubuntu command prompt by clicking the Launch button in the Windows Store or in the Start menu by choosing Ubuntu. You can also open a command prompt (or PowerShell) and run bash.

Getting started with your Linux subsystem

The first time you run your WSL distribution, you will be asked to create a user account. It can be different than your Windows username but needs to be in lowercase. You will be asked to set a password.

Creating a user in WSL.

Congratulations! Linux is running. You're now at the bash prompt, and you can run Linux commands and programs.

Update your Linux software

Now is a great time to perform a software update. Follow the instructions below to update your software with the apt command.

Like Ubuntu, WSL uses the APT (Advanced Packaging Tool) to manage software packages. The apt command lets you search for, download, and install software, all from the command line. It automatically manages your software dependencies for you. That way, if one program depends on a certain version of another program, both will be installed, and kept up-to-date.

Any apt commands that make changes to your system must run as root. If you're logged in as your regular user (as you usually should be), run a program as root by prefixing it with sudo ("superuser do"). It requires you enter your password, and your program is run as root.

sudo apt update
[sudo] password for hope:

Updates download, but nothing is installed or upgraded yet. To upgrade all available packages, run:

sudo apt upgrade
Tip

Sudo will not ask you for your password this time, unless more than five minutes have elapsed since the last sudo command.

The size of the upgrades is calculated, and you will be prompted to continue. Type y and press Enter. The upgrades download and install, which might take a while, depending on the speed of your computer and Internet connection.

When the upgrade is complete, you will be returned to the bash prompt. Your Linux system is now up-to-date.

At any time, you can exit bash using the exit command.

exit

The Windows and WSL file systems

WSL has its own file system. This Linux file system is installed to your Windows file system at the following location:

%LOCALAPPDATA%\Lxss\

For instance, if your Windows username is Owner and Windows is installed on your C: drive, your WSL file system is located at:

C:\Users\Owner\AppData\Local\Lxss\

It's good to know that this is where it's located, but you shouldn't move or make any changes to the files it contains.

When you're using WSL, you might be wondering how you can access your Windows files. Your C: drive is located at:

/mnt/c/

The name mnt stands for "mount," which is where your Windows drives are mounted within WSL. For instance, your D: drive would be /mnt/d/, etc.

For convenience, it's a good idea to create symbolic links to your Windows home folder. A symbolic link is similar to a shortcut in Windows: it's a file that points to another file or directory. When you refer to the symbolic link, the system will dereference the link, and behave as if you had specified the actual "target" file or directory.

Using symbolic links can save you a lot of typing, and remembering of obscure directory names.

To create a symbolic link in Linux, use the ln command. The syntax for creating a symbolic link is ln -s targetname linkname.

For instance, to create a symbolic link in your WSL home folder called winhome that refers to C:\Users\Owner\, follow these steps.

First, change the working directory to your home directory, which is located at /home/username/. You can do this with the cd command:

cd /home/hope/

In bash, "~" (a tilde) is an alias for your home directory, so you can also type:

cd ~

Next, use ln -s to create the symbolic link. For instance, if your Windows home folder is C:\Users\Owner\, the command would be:

ln -s /mnt/c/Users/Owner/ winhome

Now there's a symbolic link called winhome in your WSL home directory, which acts like a shortcut to your Windows home directory. So, you can change to your Windows home directory using:

cd ~/winhome/

Or, to change to your Windows desktop folder:

cd ~/winhome/Desktop/

More information about Linux commands

Enjoy your new Linux subsystem! Make sure to visit our overview of Linux commands for more information about tools and programs you can use.