Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Hosted-services / Azure

Linux BASH Shell on Windows with 'Microsoft 2.0'

4.85/5 (7 votes)
24 Oct 2017CPOL4 min read 8.8K   55  
Installing the BASH shell on Windows for use with Azure and other cloud providers

Introduction

We have come a long way from the days Steve Balmer declared Linux 'a cancer', and the culture of 'fear uncertainty and doubt' was tightly ingrained across Microsoft. I recall baulking when I heard it the first time... what a guy.... :/

Image 1

Thankfully things have moved far from that era, and we now have true visionaries at the wheel. I continue to be delighted daily by Microsoft 2.0, by their new embrace of openness and the seeming realization that sharing and integrating floats everyone to the top, and that's a very good thing. My preferred operating system for work is Windows, but I am also a heavy Linux user. Generally, I keep a Virtual Machine open for my Linux work or use a second or remote box. Recently, however, I decided to install the BASH command line tool onto all of my machines, and honestly, for most tasks, I rarely have to spin up a local virtual machine any more, I simply use the Windows Bash tool, and its highly recommended! (but might not make Steve happy!!)

Image 2

Background

This short article forms part of the DevOps/Infrastructure focused series, building out a cloud agnostic virtual machine cluster on Azure using different technologies including Terraform, Kubernetes, and Docker. In the first article in this series, I introduced 'Terraform', and gave an introduction to what it is, and how to use it. The second article discussed how to use variables, interpolation and resource count to make multiple copies of resources to save duplication of config/code. The third article covered using scripts to remotely install and update machines using Terraform scripts.

When building the foundation base virtual machines, we need to generate SSH keys, and also need to be able to remote into our machines. It turns out that having 'Bash on windows' installed makes this process much easier. This article walks through the steps of setting things up.

Installing BASH on Windows 10

Step 1

The Bash utility was actually introduced in the Windows 10 anniversity edition, and the major pre-requisite for installing it is to ensure that your version of Windows 10 is up to date, and the 64 bit version.

Step 2

Get your machine into Developer mode state.

Go into> Settings, updates and security, 'for developers', and ensure the 'Developer mode' setting is turned on. If not, turn it on, accept the warning message, and reboot your machine (do it now, I'll wait...).

Image 3

Step 3

Next, we need to go into the Control panel > Programs > Turn windows features on/off...

Image 4

In here, check the 'Linux subsystem for windows', and click OK to close the dialog.

Image 5

The system will now go through a download/install procedure, and when finished, you will need to reboot the machine.

Step 4

Now the base system is installed, we need to install and configure BASH itself. Do this by opening your search prompt (windows key + s) and looking for bash.exe. Run this program when located.

Image 6

Step 5

When the program starts, you need to accept the base ubuntu license (the Linux operating system), and let it install...

Image 7
Image 8

Step 6

After the installation process completes, you will be asked for an admin username/password..

Image 9

and finally, you now have the BASH prompt ready to use!

Image 10

If you are not familiar with Linux, here are some quick commands to get you started:

Basic Linux commands
Command Description
ls Directory listing, same as DIR in windows
ls -al Directory listing, but also shows any hidden files
pwd Display the current directory you are in
ssh user@host Use the Secure Shell utility to connect to a remote machine. 'user' is remote user you are connecting as, 'host' is the IP or domain name of the remote machine
ssh - p port user@host If you need to remotely connect on a particular port, you can specify the port after the 'p' switch
exit logs out of the BASH shell... you can also use CTRL + D
Arrow keys! ^V Use the arrow keys on your keyboard to scroll through your previously typed commands ... useful!

I also attach a very useful Linux command line CHEATSHEET that is also available on Fosswire. We will be using the BASH shell in the next part of the series that looks at setting up Kubernetes on Azure, so please do install it if you are following along.

Bye Bye Steve!

Finally, let's say goodbye to Steve who in 2007 famously declared... “There's no chance that the iPhone is going to get any significant market share. No chance.”

Hey Steve, I think you got it wrong !! :D

Image 11

History

  • 24th October, 2017: Version 1

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)