Working with Bash on Ubuntu on Windows 10

Yes, the title reads right. I'm talking about running [Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)" target="_blank), the Unix Shell on Windows. Well, on the Ubuntu subsystem running inside the Windows 10 OS. It's a bit weird, I know. And yet so cool and forward thinking.

If you need more info about how this works, you can check [this MSDN article](https://msdn.microsoft.com/en-us/commandline/wsl/about" target="_blank) that also provides links to related posts. And these people have done a great job explaining in depth how it all hangs together. They also provide installation and usage instructions which are miles better than mine.

But I'm too excited not to share. Because today, this addition to Windows made my life so much easier. I was able to work with the native tools to manage a Linux cluster. By now, my past self would be horrified with the sentence I just wrote because I hadn't touched Linux for a very long time. Let alone deploy and manage a Linux cluster on Azure! And I did it all through the command line. I was even offered the option to perform the same tasks through the GUI but I ignored it! I still chose the command line as it was faster!

The fact that got me so excited is that I was able to perform some really complex workloads all through the command line (OK, and a little bit of Visual Studio Code). It was faster and easier all together, even with the learning curve involved. What tasks did I perform you may ask?

  1. I forked the [Azure Quick Start Template() GitHub repo
  2. Copied it locally (git pull)
  3. Edited the necessary ARM template in VS Code
  4. Saved and push my changes to the remote (git push)
  5. Run the ARM template with Powershell
  6. Installed the MySQL client on Ubuntu through bash
  7. Logged into the newly deployed MySQL cluster using the MySQL client
  8. Tested the cluster failover from the command line
  9. Queried the database, created tables and inserted records
  10. I ssh(ed) into both the VMs to ensure that MySQL replication was working as expected
  11. Wiped out the cluster after I was satisfied with the results!

I didn't have to install Putty or Cygwin nor did I have to enable HyperV and install Ubuntu or another Linux distro (flavour).

It's one of these times that I felt empowered to do what I need without having to jump through 20 hoops or rely on 3rd party, half-baked solutions. It's all about using the right tool for the right job! And for this instance, we have the Windows team to thank. Because they made the Linux subsystem part of the native Windows toolchain. And it looks like this:

If you haven't tried it yet, I urge you to give it a go and hopefully you'll feel as elated as I did today (apart from the fact that I suck in using bash/cmd/powershell).


  • Share this post on