Set Up Bash On Windows 10

Introduction

Many of you who are developers and work on Windows have used either cmd or power shell. While these are great shells to use, I’m sure you’ve had trouble working with certain development tools, programming languages, and so on (Ruby anyone?) Windows. Well now, we can be like the cool Linux and Mac kids, and use Bash on Windows thanks to a push by Microsoft to add Ubuntu on Windows. This tutorial is based off Microsoft’s original tutorial and adds a few extra steps to make the transition as smooth as possible to using Bash.

The Bash Rundown

Now, you may not know what Bash is, but Bash is a shell that is packaged on the Linux OS and is compatible with other Unix system shells in terms of commands/functionality. The reason this is so important now is that most developers use a Unix-based system and are familiar with commands on Unix-based shells. The tools on Unix based systems are great for system administration and everyday tasks — giving you more power over your computer. Thus, shells like Bash are the general standard and have command line tools written for Unix before Windows; sometimes those tools never make it to Windows. Today that changes, let’s install Bash on Windows 10!

Step 1: Update Windows 10

First, your system must be a 64-bit version of Windows 10.

Now, you should update Window’s 10 if you haven’t already; this is important to leverage the full power of Bash. Here’s the link: https://www.microsoft.com/en-us/software-download/windows10 Click the update now button for the Windows 10 Creator’s Update.

Step 2: Turn On Developer Mode

To turn on Developer mode open Settings -> Update and Security -> For developers. Select the Developer Mode radio button in the panel. Here’s a screenshot:

Now, you need to enable the Windows Subsystem for Linux feature. Search for “Windows’ Features” in your search bar; turn on/off Windows features should appear. Here’s another screenshot:

Finally, enable the Window’s Subsystem for Linux via the command line using power shell as an administrator. Search for “power shell” using your search bar, right click the program and click “run as administrator”. Type this command in the box: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Once you’re done with this step, restart your computer; it’s important that you restart when prompted.

By turning on Developer mode, you gain access to more developer applications on Windows 10, that you wouldn’t have access to otherwise. Furthermore, it’s a requirement if you want to use Bash on Windows. All the hard work is out of the way on to the next step!

Step 3: Install Ubuntu On Windows

Here we install Ubuntu on Windows, giving us access to Bash and a Linux-based subsystem on Windows. We can even access Windows files from our Linux-based subsystem.

Now, open a command prompt on Windows; you can do this by typing “cmd” into your search bar. Next, type bash in the command prompt. It will then install Ubuntu on your computer. Once the installation is complete, it will ask you for a username and password. Note, when typing in your password, you won’t see it in the command prompt.

Congratulations! You now have Bash on your Window’s computer! The next steps are optional but will help you use Bash smoothly on your computer.

Step 4: Setup Bash And Linux Subsystem

Now, we make some necessary edits to our Linux environment, so we can run Windows Applications from Bash smoothly.

  1. Update your path variable in .bashrc
    Open your bash prompt on Window’s 10; search for “bash”. Type ls -a to see hidden files. Next, type nano .bashrc . Scroll to the bottom of the file and type: PATH=$PATH:/mnt/c/Windows/System32/
    export PATH

    Now, we can access our basic Windows applications from Bash like explorer.exe. To use Windows applications, we must type “.exe” at the end. If you want to add more Windows applications to the list edit this file again and separate each path with a colon (:).
  2. Link your documents folder to your home directory in bash
    In your prompt, type: ln -s /mnt/c/Users/yourUsername/Documents/ documents
    Replace yourUsername with your own (it’s case-sensitive). This creates a soft link to your current user’s document directory, so you can easily get to your files.

And with that, you’re done setting up Bash! Restart your prompt by closing it and opening it again.

Hope you all enjoyed this tutorial and enjoy your newfound powers; you can easily install things like Ruby, Node.js, etc right from your command line and run them on Windows! sudo apt-get install ruby Once again, enjoy and hope you learn a lot by using Linux; you can do a lot more with your computer and have to worry less about compatibility issues between you and those cool Mac and Linux kids.

Extra Sources

Microsoft Guide

Bash GNU Link

Microsoft Guide: Using Window’s Applications from Bash

Leave a Reply

Your email address will not be published.