Setting Up Linux on Windows with WSL
This is a basic guide to installing the Ubuntu command line on Windows using WSL, the Windows Subsystem for Linux. This guide is neither unique nor exhaustive: I've just given these instructions to enough people that I thought I'd put it up online.
Ensure you're compatible
Your computer needs to be running Windows 10 version 1709 or higher. You can check this in system settings:
Press Windows Key → Search "About your PC" → Scroll to the bottom → Make sure the Edition is some form of Windows 10 other than Windows 10 S, make sure the Version is at least 1709
If the version number is lower than 1709, you don't have the Fall Creators Update. Even if you do, I’d recommend double checking that you’re all the way updated, since Microsoft has added new features to the WSL platform in more recent updates.
Press Windows Key → Search “Check for updates”
You need to manually enable the Windows Subsystem for Linux:
Press Windows Key → Search "Turn Windows features on or off" → Scroll to the bottom → Check the box for Windows Subsystem for Linux → Restart your computer
The restart may take several minutes, since your computer is enabling WSL. After this first time, restarts and the like won't take any longer than usual.
Now that WSL is enabled, you need to install a form of Linux that uses it. Ubuntu is a good default and is suitable for almost anything you'd want to do. You can get it by clicking this link on your computer or by doing the following:
Press Windows Key → Search "Microsoft Store" → Use the search bar in the top right to search "Ubuntu" → Install the Ubuntu app
Once the app is downloaded, set it up by launching it. The store page you installed it from will have a button to launch it, or you can search for it:
Press Windows Key → Search "Ubuntu"
Ubuntu may take several minutes to load. Eventually, it will ask you to create a username and password. They can be whatever you like, but make sure you keep track of them. Note that when entering the password, the characters won't show up: the computer is registering them perfectly fine, it just doesn't show the password while you're typing it.
Once that is finished, you're done with the installation! A significant note: whenever something in Linux asks for your password, it doesn’t want your Windows password, it wants the Linux password you just set.
Entering and Exiting
If you just completed the part above, you already have the Ubuntu bash shell open. To open it in the future, I use the following steps:
Press Windows Key → Type “cmd” → Press enter → Type “bash” → Press enter
Why use this method when we could just run the Ubuntu app or directly search for “bash” from the Windows Search? It has to do with what folder we want to start our Linux bash shell in: running the Ubuntu app will start you in your Linux home folder, denoted with a tilde. That’s all well and good, but we can’t get to our Linux user home folder from within normal Windows, while we can get to our Windows home folder from within Linux.
That’s certainly confusing: another way to phrase it is that Linux can see all your Windows folders, but Windows can’t see your Linux folders. The bottom line is we’d like to use our Linux shell over on the Windows side of the filesystem so we can always access our files. When you open the normal Windows command prompt with “cmd,” the Windows command prompt starts in your Windows home folder. If you run “bash” from there, you’ll start the Linux shell in your Windows home folder (look closely at the blue text in the image above: does “c/Users/<user name>” look familiar?).
So why can’t we just search for “bash” directly? Remember that running “bash” picks up the folder where we are running it from: running it from Windows search will start us off from the Windows System32 folder. It might be a few more steps to launch the Linux shell by using “cmd” and then “bash,” but it will save you time later because you won’t have to change your directories as much.