Brief: This beginners tutorial shows you how to install bash on Windows.
Linux on Windows is a reality, thanks to the partnership between Canonical (parent company of Ubuntu) and Microsoft. When Microsoft CEO announced that Bash shell is coming to Windows, a number of people just couldn’t believe it. #BashOnWindows trended on Twitter for days, such was the impact of this news.
But Bash on Windows was not available to everyone immediately. People had to install Windows 10 technical preview to install Linux on Windows 10. But this is not the case anymore. Windows 10 anniversary upgrade is here and now you can easily get bash on Windows. But before we go on installing bash on Windows, let me tell you a little more about it.
What is Bash on Windows?
Bash on Windows provides a Windows subsystem and Ubuntu Linux runs atop it. It is not a virtual machine or an application like Cygwin. It is complete Linux system inside Windows 10.
Basically, it allows you to run the same Bash shell that you find on Linux. This way you can run Linux commands inside Windows without the need of installing a virtual machine or dual booting Linux and Windows. You install Linux inside Windows like a regular application. This is a good option if your main aim is to learn Linux/Unix commands.
I recommend reading this article to know more about Bash on Windows.
Method 1: Install Linux Bash Shell on Windows 10 Fall’s Creator Update
Good thing is that Fall’s Creator Update makes it easier to install Bash on Windows 10. You can get it in one click from Windows Store. There are still a few things to do however.
I am installing Ubuntu using Windows 10 Linux subsytem. You can also use SUSE Linux. The procedure is same for both distributions.
Step 1: Enable “Windows Subsystem for Linux” feature
The first thing you need to do is to enable Windows Subsyetm for Linux feature from PowerShell.
Go to Start menu and search for PowerShell. Run it as administrator:
Once you have the PowerShell running, use the command below to enable Bash in Windows 10.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
You’ll be asked to confirm your choice. Use Y or press enter:
Now you should be asked to reboot. Even if you are not asked to, you must restart your system.
Step 2: Download a Linux system from Windows store
Once your system has rebooted, go to Windows Store and search for Linux.
You’ll see the option to install Ubuntu or SUSE. I have installed Ubuntu for Bash on Windows here.
What’s the difference between using Ubuntu or openSUSE or SUSE Linux Enterprises? And which one should you use?
If that’s your question then perhaps you don’t know much about Linux distributions. To tell you quickly, the main difference would be in the commands for installing new packages inside these Linux subsytems. I advise going for Ubuntu in this case.
Once you choose the distribution of your choice, you’ll see the option to install it. Do note that it will download files of around 1Gb in size. So you should have a good internet connection here.
Step 3: Run Linux inside Windows 10
You are almost there. Once you have installed, it’s time to see how to access Bash in Windows 10.
Just search for the Linux distribution you installed in the previous step. In my case it was Ubuntu. You’ll see that it runs like a normal Windows application.
It will take some time in installing and then you’ll have to set up the username and password.
Don’t worry, it’s just for the first run. Bash shell will be available for use directly from the next time onwards.
Enjoy Linux inside Windows 10.
Troubleshooting 1: The WSL optional component is not enabled. Please enable it and try again.
You may see an error like this when you try to run Linux inside Windows 10:
The WSL optional component is not enabled. Please enable it and try again. See https://aka.ms/wslinstall for details. Error: 0x8007007e Press any key to continue...
And when you press any key, the application is closed immediately.
The reason here is that the Windows Subsyetm for Linux is not enabled in your case. You should enable it as explained in step 1 of this guide. You can do that even after you have installed Linux from Windows Store.
Troubleshoot 2: Installation failed with error 0x80070003
This is because Windows Subsystem for Linux only runs on the system drive i.e. the C drive. You should make sure that when you download Linux from Windows Store, it is stored and installed in the C Drive.
Go to Settings -> Storage -> More Storage Settings: Change where new content is saved and select C Drive here.
Method 1: Install Linux Bash Shell on older Windows 10
If you cannot get the Fall’s Creator update on Windows 10 for some reason, you can still install it if you have the Anniversary update of Windows 10. But here, you’ll have to enable the developer mode. I still recommend upgrading to Fall’s Creator update though.
Press Windows Key + I to access Windows system settings. In here, go to Update & Security:
In here, from the left side pane, choose ‘For developers’. You’ll see an option of ‘Developer mode’. Enable it.
Now search for Control Panel and in Control Panel, click on “Programs”:
In Programs, click “Turn Windows Features On or Off”:
When you do this, you’ll see several Windows features. Look for “Windows Subsystem for Linux” and enable it.
You’ll need to restart the system after doing this.
After restarting the computer, click the start button and search for “bash”.
When you run it for the first time, you’ll be given the option to download and install Ubuntu. You’ll be asked to create username and password during this process. It will install entire Ubuntu Linux, so have patience as it will take some time in downloading and installing Linux on Windows.
Once this is done, go back to Start menu and search for Ubuntu or Bash.
Now you have got a command line version of Ubuntu Linux. You can use apt to install various command line tools in it.
I hope you find this tutorial helpful to install bash on Windows 10. I let you play with Linux inside Windows. If you have questions or suggestions, feel free to ask.