Installing Bash on Ubuntu on Windows 10 Insider Preview

___________________________________________________________________________________________________________________________

IMPORTANT ANNOUNCEMENT FOR OUR READERS!

AskPFEPlat is in the process of a transformation to the new Core Infrastructure and Security TechCommunity, and will be moving by the end of March 2019 to our new home at https://aka.ms/CISTechComm (hosted at https://techcommunity.microsoft.com). Please bear with us while we are still under construction!

We will continue bringing you the same great content, from the same great contributors, on our new platform. Until then, you can access our new content on either https://aka.ms/askpfeplat as you do today, or at our new site https://aka.ms/CISTechComm. Please feel free to update your bookmarks accordingly!

Why are we doing this? Simple really; we are looking to expand our team internally in order to provide you even more great content, as well as take on a more proactive role in the future with our readers (more to come on that later)! Since our team encompasses many more roles than Premier Field Engineers these days, we felt it was also time we reflected that initial expansion.

If you have never visited the TechCommunity site, it can be found at https://techcommunity.microsoft.com. On the TechCommunity site, you will find numerous technical communities across many topics, which include discussion areas, along with blog content.

NOTE: In addition to the AskPFEPlat-to-Core Infrastructure and Security transformation, Premier Field Engineers from all technology areas will be working together to expand the TechCommunity site even further, joining together in the technology agnostic Premier Field Engineering TechCommunity (along with Core Infrastructure and Security), which can be found at https://aka.ms/PFETechComm!

As always, thank you for continuing to read the Core Infrastructure and Security (AskPFEPlat) blog, and we look forward to providing you more great content well into the future!

__________________________________________________________________________________________________________________________

Hello again, Allen Sudbring here Premier Field engineer in the Central Region. Today I want to talk about an exciting new feature coming with the Anniversary update to Windows 10 that was announced at the Build 2016 conference, Bash command Shell on Windows 10. I am extremely excited about this feature because I work with Linux and Windows VM’s and being able to manage both from one command shell window and move from CMD, to PowerShell, to Bash increases productivity for both IT administrators and developers.

Microsoft has partnered with Canonical, the makers of Ubuntu, to bring the Bash shell to Windows. To make this happen, a new Windows Subsystem for Linux was created for Windows 10. Think of it sort of like reverse WINE, which is the Linux application that allows Windows programs to run on Linux. Most shell applications such as apt, git and editors like nano will work inside of this shell running in Windows.

More Information on the Windows Subsystem for Linux:

Windows Subsystem for Linux Overview

From <https://blogs.msdn.microsoft.com/wsl/2016/04/22/windows-subsystem-for-linux-overview

Before I get started on how to install it, I need to put in a disclaimer that this is pre-release software that could change when the Anniversary update is released later this year. Screens and menus can also change in subsequent builds of the Windows Insider Preview.

Now that we have that out of the way, let’s look at some prerequisites for enabling the Bash shell:

· Computer enrolled in the Windows 10 Insider Preview Program in the Fast Ring. (NOTE: It can take up to 24 hours for computer to register with Insider Preview program and receive fast ring build)

· Build 14136 or later from Insider preview program installed on Computer

Once you have confirmed that the computer is in the Fast ring and you have received Build 14136 or newer, you can proceed with installing the Bash shell in windows.

Login to the machine, and open Settings:

image

Click on “Update and Security”:image

Click on “For Developers” in the left hand navigation pane and select the developer mode radio button:

image

Click Yes to enable Developer Mode:

image

Verify it’s enabled:

image

Close settings and open Control Panel and click on “Programs”:

image

Click “Turn Windows Features on or off”:

image

Check the box next to “Windows Subsystem for Linux (Beta)” and click OK:

image

image

Click the “Restart Now” button when the install is completed:

image

Login to the computer once it has rebooted and open a command prompt as administrator:

image

Type “Bash” at the command prompt and press “Y” to continue:

image

Bash and the support file system will be downloaded from the Windows Store:

image

The file system will be extracted and installed. Can take a few minutes to complete:

image

The final configuration step is to create a user. Enter a username when prompted:

NOTE: This step was not in the original build that was released after the Build Conference I have added it here as an update to demonstrate that the default user is no longer root

image

Enter a password when prompted:

image

Re-enter the password when prompted.

Once the installation is completed, it will give a status of successful and open the bash prompt with the C: drive mounted:

image

You can get to the shell by opening a command prompt and typing Bash or click the link that is added in the Start Menu:

image

All normal commands work. Example below is sudo apt-get update:

image

Nano text editor:

image

SSH:

image

Running remote command on Linux container host using SSH on Bash on Ubuntu on Windows:

image

Removal

For some reason, if you need to remove the shell or something isn’t working, you can open an elevated command prompt and run the following command:

lxrun /uninstall /full

image

About the only thing that can’t be run or supported in the shell is a Windows Manager such as KDE or GNOME.

We covered what the new Bash shell on Ubuntu is in Windows 10 as well as how to install it and get started.

I didn’t think I would ever see the day of a Linux shell running on Windows that wasn’t Cygwin or a third party application such as PUTTY. I am very excited about this and the other features coming in the anniversary update for Windows 10 and I hope you are too!!