Installing Windows Subsystem for Linux (WSL)
UNIX, Linux, and Posix
When interacting with a computer's file system or other computers over a network, it is increasingly important for one to be familiar with UNIX/Linux ("*NIX") operating systems. In this class, our course server is running on a Linux system, and people using an Apple macOS computer are running a variant of UNIX. When these people launch a Terminal window, they issue commands in that interface that follow the POSIX protocol.
What about Windows?
The Command Prompt application in Windows is similar to a Terminal, but doesn't use the same POSIX standards. (The POSIX command for listing the files in a directory is ls
, for example, while the Windows command is dir
.) Windows does allow one to install and use a POSIX-compliant Terminal window that runs in the "Windows Subsystem for Linux."
Here's how to enable/install WSL.
Installing the Windows Subsystem for Linux
- Download Ubuntu
Start up your Windows machine and use the search tool to download and then install an Ubuntu from the Microsoft Store. Get one of the ones that has "LTS" listed in the name. - Enable Linux subsystem
Launch the Ubuntu app and you'll (probably) get a message that the Windows Subsystem for Linux has not been enabled. Follow the onscreen instructions to enable WSL.There will be an indication that Windows needs to be rebooted. Go ahead and restart Windows.
- Launch Ubuntu's Terminal
The first time you launch the Ubuntu app you'll be asked to create a username and password, which can be different from your regular Windows username and password. Note that when you type in the password in the terminal window, nothing will be echoed on screen, not even dots or asterisks. This behavior is normal. - Launch a Terminal window
You can now launch a Terminal window by typing "bash" or "ubuntu" into the Menu Bar's Search field.
Congratulations! Your Windows machine is now POSIX compliant!
Reconciling your two home directories
The Ubuntu/Linux/bash subsystem that you've installed runs under a username that is not connected to your regular Window's system. The home directory on your Ubuntu system is not the same as the home directory on Windows.
If you want to use bash to access your Windows directory, you'll need to issue a command like this into the terminal when it launches:
$ cd "/mnt/c/Users/Richard White/"
From here you'll be able to find your Windows files without difficulty.
If you decide you'd like to have your home directory in bash actually be the home directory in Windows, you can:
- In a new terminal session (in your Ubuntu home directory) type
nano .bashrc
. This will allow you to edit that file and have it re-direct your home directory. - At the end of that file, including the following two lines.
HOME="/mnt/c/Users/Richard White" cd ~
Use your own username rather than Richard White, of course. - Close the current Terminal window and open a new one. You should find yourself redirected to your Windows home directory, and you can proceed accordingly.
