The joy of bash on Windows

By | September 5, 2017

One of the things I like best about running a Linux desktop is the bash shell, which is great for connecting to other boxes, editing files, running Docker containers — you name it. So, when Microsoft introduced the bash shell for Windows 10, I was skeptical.

After all, I’ve used cmd.exe for years and it’s nothing like a Linux terminal. PowerShell, Microsoft’s answer to the Linux (and Mac) shell, is an improvement, but it still lacks the simplicity and a lot of what I love about bash. My solution was to ignore the new Microsoft offering altogether.

Turns out, that was a mistake.

Though I admittedly and purposely entered the Windows 10 world late, I hadn’t given the bash offering much credence, particularly since Windows isn’t my primary desktop. But installing it was straightforward and I soon discovered that the “Windows Subsystem for Linux (Beta)” is really just a Windows 10 feature you can turn on and off. More importantly, it doesn’t just install bash, it installs an entire working Ubuntu 16.04 Linux environment.

To get it running on your system, follow the instructions found in these two posts:

  1. How to enable Developer Mode in Windows 10 to sideload apps
  2. How to get Bash on Windows 10

After following the instructions in Step #2, you’ll launch bash from the Windows 10 Start Menu (just start typing “bash” and it’ll come up). The first time you do, it’ll prompt you and ask if you want to install the environment. Type a “y” to complete the setup.

After you reboot, again launch bash from the Start Menu (or add it to your taskbar for quick-launching like I did). This time, the console window will drop you at the bash command prompt. Run a quick “cd” or “cd ~” to drop into your home directory and enter “pwd”. The result is something like:

/home/username

If you do an “ls /” you’ll see a standard Ubuntu file system tree. If you’re wondering where all your Windows 10 stuff is, just look in /mnt/c. That’ll show you the contents of your Windows C:\.

As I put bash on Windows 10 through its paces, I found I could add all my .bashrc customizations, add a .bashrc_aliases, create ssh keys (ssh-keygen), ssh into anything, run ifconfig to show network settings, run Ansible automation playbooks, and even run apt.

From now on, instead of using putty or another third-party Windows-based shell tool, I can use a real Linux shell. Now, all my platforms benefit from the benefits of Linux!