Installing the Linux Bash Shell on Windows 10

Windows 10’s Anniversary Update offered a new feature for developers: A full Ubuntu-based Bash shell that can run Linux commands on a Windows 10 client. This is possible by using the new “Windows Subsystem for Linux” Microsoft added to Windows 10.

This isn’t a virtual machine or Linux software compiled for Windows. Microsoft worked with Canonical to offer a full Ubuntu-based Bash shell. This isn’t Linux, it is just the Bash shell and the exact same binaries you’d normally run on Ubuntu Linux.

It’s intended for developers who want to run Linux command-line utilities on Windows. They’ll get access to the Windows file system, but you can’t use Bash commands to automate normal Windows programs, or launch Bash commands from the standard Windows command-line.

How to Install Bash on Windows 10

To get started, make sure you have installed the Windows 10 Anniversary Update (build 14316 or higher). This also only works on 64-bit builds of Windows 10.

Once you’re sure you’re using the correct version of Windows 10, open the Settings app and go to Update & Security > For Developers. Activate the “Developer Mode” switch here to enable Developer Mode.

@SeniorDBA

Next, open the Control Panel, click “Programs,” and click “Turn Windows Features On or Off” under Programs and Features. Enable the “Windows Subsystem for Linux (Beta)” option in the list here and click “OK.”

After you do, you’ll be prompted to reboot your computer. Click “Restart Now” to reboot your computer and Windows 10 will install the new feature.

@SeniorDBA

After your computer restarts, click the Start button (or press the Windows key), type “bash”, and press “Enter.”

The first time you run the bash.exe file, you’ll be prompted to accept the terms of service. The command will then download the “Bash on Ubuntu on Windows” application from the Windows Store. You’ll be asked to create a user account and password for use in the Bash environment.

If you’d like to automate the installation of Bash instead, you can run the following command in a Command Prompt window. This will automatically agree to all prompts and set the default user to “root” with no password:

lxrun /install /y

Using Ubuntu’s Bash Shell

You now have a full command-line bash shell based on Ubuntu, which means you can use Ubuntu’s apt-get command to install software from Ubuntu’s repositories. You’ll have access to all the Linux command line software out there.

To open the Bash shell, just open your Start menu and search for “bash” or “Ubuntu.” You’ll see a “Bash on Ubuntu on Windows” application. You can pin this application shortcut to your Start menu, taskbar, or desktop for easier access.

If you’re experienced using a Bash shell on Linux, Mac OS X, or other platforms, you’ll be right at home. You don’t need to use sudo, as you’re given a root shell. The “root” user on UNIX platforms has  full system access, like the “Administrator” user on Windows. Your Windows file system is located at /mnt/c in the Bash shell environment.

Use the same Linux terminal commands you’d use to get around. If you’re used to the standard Windows Command Prompt with its DOS commands, here are a few basic commands on both Bash and Windows:

  • Change Directory: cd in Bash, cd or chdir in DOS
  • List Contents of Directory: ls in Bash, dir in DOS
  • Move or Rename a File: mv in Bash, move and rename in DOS
  • Copy a File: cp in Bash, copy in DOS
  • Delete a File: rm in Bash, del or erase in DOS
  • Create a Directory: mkdir in Bash, mkdir in DOS
  • Use a Text Editor: vi or nano in Bash, edit in DOS

It’s also important to remember that the Bash shell and its Linux-imitating environment are case-sensitive. Unlike Windows, “MyFileName.txt” is different from “myfilename.txt”, just because of the use of capital letters in the name.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s