Install Bash on Ubuntu on Windows
Posted by Dave Eddy on Oct 17 2017 - tags: techLast week I made a big change in my life. In 2008, I switched off of using Windows (and even Linux) as my main Operating System for my laptop and haven’t looked back… until this year. Last week I finally made the jump and bought a Microsoft Surface Pro.
I wanted something like an iPad, but that didn’t feel like a crippled version of a computer. Instead, I wanted something that was a powerful computer that could double as a tablet (touchscreen and removable keyboard mostly).
Note: Some, if not all, of this guide may be deprecated with the release of the Windows 10 Fall Creators Update in 2017.
A couple months ago I had my life changed when I first tried Jaden’s laptop with a touchscreen. Since I have most of my experience with Mac (almost 10 years using Mac as my main laptop), I was a bit slow using Windows. Seeing her reach out and touch the screen to do things I was struggling to do with the trackpad first blew my mind. Then, actually using the touchscreen myself in conjunction with the trackpad/keyboard combo blew my mind again at how quickly it clicked and made sense to me.
The touchscreen is great, the keyboard is amazing (even better than my 2015 Macbook), and using it as a tablet in portrait mode just works so well. However, it’s still Windows, and as such it doesn’t have a Unix base. I knew that without being able to open a terminal locally on my machine, that would be a deal breaker - I need a Unix based terminal on my computers in order to use them efficiently (spoiler: I’m writing this blog post in vim in a terminal on my Surface Pro).
Summary
Enter the Windows Subsystem for Linux. Just like how SmartOS has LX-Branded Zones, the WSL is a layer that emulates the syscall table for Linux in the Windows environment. No actual Linux kernel is running, but the userland runs just fine since all of the facilities and libraries it expects are there.
This feature of Windows is the only reason that I could successfully switch from Mac to Windows as an Operating System I use to get work done.
Installation
To install Bash on Ubuntu on Windows is a fairly straight-forward process. There are a couple of guides online, but some of them seem to miss key steps that caused me some headache when installing it myself.
1. Enable Developer Mode
Open the settings in Windows 10, go into “Update & security”, click “For developers”, and check “Developer mode”.
2. Enable Windows Subsystem for Linux
To enable the WSL, open a PowerShell instance as the Administrator user. To do this, open the start menu (press the Windows key on the keyboard), start typing “PowerShell”, and right click the main result and select “Run as administrator”.
With the admin shell open, run the following command. This will require a reboot to complete.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
3. Install Bash
To install bash, open a Command prompt by opening the start menu and typing in “cmd” and opening the first result. With it open, type in “bash” and hit enter to install bash. This will handle downloading it, and creating the local Unix user.
The username and password are just for the Unix user and have no effect on the current Windows user. I used the same username for Unix as I did for Windows, but you don’t have to.
Enjoy the Terminal
And now, you have a real terminal! To quickly open bash, open the start menu, search for “bash” and open the first result. I have this shortcut on the desktop and pinned to my start bar as well.