Just as we were going to press with this book, Microsoft released the bash shell for Windows—and how could we publish a book on shell script programming without telling you about this new option?
The wrinkle is that you need to be running not just Windows 10 but the Windows 10 Anniversary Update (build 14393, posted August 2, 2016). You also need to have an x64-compatible processor and be a member of the Windows Insider Program. And then you can start installing bash!
Start by joining the Insider Program at https://insider.windows.com/. It’s free to join and will provide you with a convenient way to update your Windows release to the Anniversary release. The Insider Program has a Windows 10 Upgrade Assistant that will prompt you to update, so use that to update to the required release. This might take a little while, and you’ll need to restart.
Once you’ve enrolled in the Windows Insider Program and have the Anniversary version of Windows 10 installed, you’ll need to get into Developer mode. To start, go to Settings and search for “Developer mode.” The Use developer features section should come up. From here, select Developer mode, as shown in Figure A-1.
Figure A-1: Enabling Developer mode in Windows 10
When you select Developer mode, Windows might warn you that going into Developer mode may expose your device to harm. The warning is legit: going into Developer mode does put you at greater risk because you can inadvertently install programs from non-approved sites. However, if you can remain careful and vigilant, we encourage you to proceed so you can at least test out the bash sytem. After you click through the warning, Windows will download and install some additional software onto your computer. This takes a few minutes.
Next, you’ll have to go into the old-school, early Windows configuration area to enable the Windows Subsystem for Linux. (It’s very cool that Microsoft even has a subsystem for Linux!) Get there by searching for “Turn Windows Features On.” A window will open with a long list of services and features, all with check boxes (see Figure A-2).
Don’t uncheck anything; you only need to check Windows Subsystem for Linux (Beta). Then click OK.
Your Windows system will prompt you to restart to fully enable the Linux subsystem and the new developer tools. Do so.
Figure A-2: The Turn Windows features on or off window
Now you’re ready to install bash from the command line! Old school, for sure. In the Start menu, search for “command prompt” and open a command window. Then simply enter bash and you’ll be prompted to install the bash software on your PC, as shown in Figure A-3. Enter y and bash will start to download.
Figure A-3: Installing bash within the command line system on Windows 10
There’s a lot to download, compile, and install, so this step will also take a while. Once it’s all installed, you’ll be prompted to enter a Unix username and password. You can choose whatever you want; they don’t need to match your Windows username and password.
Now you have a full bash shell within your Windows 10 system, as shown in Figure A-4. When you open your command prompt, you can just enter bash and bash is ready to use.
Figure A-4: Yes, we’re running bash within the command prompt. On Windows 10!
At this point, bash on Windows seems like more of a curiosity than anything that’s going to be tremendously useful for Windows 10 users, but it’s good to know about. If you only have a Windows 10 system available to you and you want to learn more about bash shell script programming, give it a try.
If you’re more serious about Linux, dual-booting your PC with a Linux distribution or even running a full Linux distro within a virtual machine (try VMware for a great virtualization solution) is going to serve you better.
But still, props to Microsoft for adding bash to Windows 10. Very cool.