- How to Install Linux Bash Shell on Windows 10
- What is Bash on Windows?
- Method 1: Install Linux Bash Shell on Windows 10 Newer Versions
- Step 1: Enable “Windows Subsystem for Linux” feature
- Step 2: Download a Linux system from the Windows store
- Step 3: Run Linux inside Windows 10
- Troubleshooting 1: The WSL optional component is not enabled. Please enable it and try again.
- Troubleshoot 2: Installation failed with error 0x80070003
- Method 2: Install Linux Bash Shell on older Windows 10
- Step 1:
- Step 2:
- Step 3:
- Step 4:
- Step 5:
- Step 6:
- Step 7:
- Step 8:
- Step 9:
- Step 10:
- Bonus Tip: Run GUI Apps On Windows Subsystem for Linux
- Step 1: Enable/Update WSL 2
- Step 2: Download and Install a Windows X Server Program
- Step 3: Configure Windows X Server
- Unix-like shells on Windows
- PowerShell
- Eshell
- Clink
- Conclusion
How to Install Linux Bash Shell on Windows 10
Last updated October 29, 2020 By Abhishek Prakash 104 Comments
Brief: This beginner’s 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’s CEO announced that the Bash shell was 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 the Windows 10 technical preview to install Linux on Windows 10. But this is not the case anymore. The Windows 10 anniversary upgrade is here and now you can easily get Bash on Windows. And, before we go on installing Bash on Windows, let me tell you a little more about it.
Note: This tutorial was tested with the latest available Windows 10 version 2004 and build 19041.450. You might need to update your Windows installation if you’ve an older build to follow everything in this tutorial.
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 needing to install a virtual machine, or dual boot 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 Newer Versions
Good thing is that the Fall Creator’s Update and the recent Windows 10, version 2004 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 Subsystem for Linux. 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 Subsystem for Linux feature from PowerShell or from the Windows feature options.
If you want to utilize the GUI, you can simply search for option to get the list of Windows features to enable a few things as shown in the screenshot below.
Now, you just have to open it to access all the options. Among the ones listed, you have to enable (or check) the feature for “Windows Subsystem for Linux” and “Virtual Machine Platform” and then perform a reboot to make sure you have both of them enabled.
In either case, if you want to utilize the PowerShell, you can just go to the 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.
You’ll be asked to confirm your choice. Type 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 the Windows store
Once your system has rebooted, go to the Windows Store and search for “Linux” or just “Ubuntu”.
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 Enterprise? And which one should you use?
To tell you quickly, the main difference would be in the commands for installing new packages inside these Linux subsystems. 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 or less depending on what you’re downloading.
Step 3: Run Linux inside Windows 10
You are almost there. Once you have installed Linux, 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 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:
And when you press any key, the application closes immediately.
The reason here is that the Windows Subsystem 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 the 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 2: Install Linux Bash Shell on older Windows 10
If you cannot get the Fall Creator’s 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 developer mode. I still recommend upgrading to the Fall Creator’s update or the latest Windows 10 2004 version update though.
Step 1:
Press Windows Key + I to access Windows system settings. In here, go to Update & Security:
Step 2:
From the left side pane, choose “For developers.” You’ll see an option for “Developer mode.” Enable it.
Step 3:
Now search for Control Panel and in Control Panel, click on “Programs”:
Step 4:
In Programs, click “Turn Windows features on or off”:
Step 5:
When you do this, you’ll see several Windows features. Look for “Windows Subsystem for Linux” and enable it.
Step 6:
You’ll need to restart the system after doing this.
Step 7:
After restarting the computer, click the start button and search for “bash”.
Step 8:
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 a username and password during this process. It will install an entire Ubuntu Linux system, so have patience as it will take some time in downloading and installing Linux on Windows.
Step 9:
Once this is done, go back to the Start menu and search for Ubuntu or Bash.
Step 10:
Now you have a command line version of Ubuntu Linux. You can use apt to install various command line tools in it.
Bonus Tip: Run GUI Apps On Windows Subsystem for Linux
The ability to run GUI apps on Windows Subsystem for Linux was introduced with WSL 2 release in May 2020.
It’s still not something officially supported out-of-the-box, but if you’re curious, you can experiment with it by following the steps below:
Step 1: Enable/Update WSL 2
If you have the latest Windows version 2004, build 19041, you already have WSL 2 support but you need to enable it and set it to default instead of WSL 1.
To do that, first you need to ensure that you have the latest WSL 2 Linux Kernel by updating the WSL 2 Linux Kernel.
You just need to follow the instructions on the official documentation page and download/install the package. Once done, you need to launch the PowerShell (run it as administrator) and set WSL 2 as the default by typing the following command:
You should get a message that says “For information on key differences with WSL 2 please visit https://aka.ms/wsl2”.
In case you get an error (Error: 0x1bc), you need to make sure that you have updated the WSL 2 Linux Kernel, that solved the issue for me.
Step 2: Download and Install a Windows X Server Program
As I mentioned, WSL 2 does not have the official support for running GUI apps by default. So, to do it, we need to download and install a Windows X Server program to give WSL access to display the apps.
You can try the open-source XLaunch server that we’re using here.
Step 3: Configure Windows X Server
Now that you have installed it, you just need to configure a few things.
First, Launch XLaunch and proceed to ensure that you have the following options enabled:
1. Keep the Display number set as -1 and select “Multiple Windows“
2. Next, you need to enable “Start no client“.
3. Finally, you just need to check “Disable access control” to avoid permission issues and save the configuration on the next step to complete the configuration.
Now everything’s almost done, you need to launch Ubuntu from the list of apps installed and configure it to launch Linux GUI apps on Windows.
Just enter the following command in the Linux terminal (Ubuntu):
Now, just install your favorite Linux GUI app from the terminal and test if it works! In my case, I installed and launched Gedit using the following commands:
And, here’s how it looks:
I hope you find this tutorial helpful for installing bash on Windows 10 and experimenting Linux GUI apps on Windows 10. No wonder WSL lets you play with Linux inside of Windows. If you have questions or suggestions, feel free to ask.
Like what you read? Please share it with others.
Unix-like shells on Windows
This post gives some notes on ways to create a Unix-like command line experience on Windows, without using a virtual machine like VMWare or a quasi-virtual machine like Cygwin.
Finding Windows ports of Unix utilities is easy. The harder part is finding a shell that behaves as expected. (Of course “as expected” depends on your expectations!)
There have been many projects to port Unix utilities to Windows, particularly GnuWin32 and Gow. Some of the command shells I’ve tried are:
I’d recommend the combination of Gow and Clink for most people. If you’re an Emacs power user you might like Eshell.
The built-in command line on Windows is cmd . It’s sometimes called the “DOS prompt” though that’s misleading. DOS died two decades ago and the cmd shell has improved quite a bit since then.
cmd has some features you might not expect, such as pushd and popd . However, I don’t believe it has anything analogous to dirs to let you see the directory stack.
PowerShell
PowerShell is a very sophisticated scripting environment, but the interactive shell itself (e.g. command editing functionality) is basically cmd . (I haven’t kept up with PowerShell and that may have changed.) This means that writing a PowerShell script is completely different from writing a batch file, but the experience of navigating the command line is essentially the same as cmd .
Eshell
You can run shells inside Emacs. By default, M-x shell brings up a cmd prompt inside an Emacs buffer. You can also use Emacs’ own shell with the command M-x eshell .
Eshell is a shell implemented in Emacs Lisp. Using Eshell is very similar across platforms. On a fresh Windows machine, with nothing like Gow installed, Eshell provides some of the most common Unix utilities. You can use the which command to see whether you’re using a native executable or Emacs Lisp code. For example, if you type which ls into Eshell, you get the response
The primary benefit of Eshell is that provides integration with Emacs. As the documentation says
Eshell is not a replacement for system shells such as bash or zsh . Use Eshell when you want to move text between Emacs and external processes …
Eshell does not provide some of the command editing features you might expect from bash . But the reason for this is clear: if you’re inside Emacs, you’d want to use the full power of Emacs editing, not the stripped-down editing features of a command line. For example, you cannot use ^foo^bar to replace foo with bar in the previous command. Instead, you could retrieve the previous command and edit it just as you edit any other line inside Emacs.
In bash you can use !^ to recall the first argument of the previous command and !$!$ using $_ instead. Many of the other bash shortcuts that begin with ! work as expected: !foo , !! , !-3 , etc. Directory navigation commands like cd — , pushd , and popd work as in bash .
Gow comes with a bash shell, a Windows command line program that creates a bash -like environment. I haven’t had much experience with it, but it seems to be a faithful bash implementation with few compromises for Windows, for better and for worse. For example, it doesn’t understand backslashes as directory separators.
There are other implementations of bash on Windows, but I either haven’t tried them (e.g. win-bash) or have had bad experience with them (e.g. Cygwin).
Clink
Clink is not a shell per se but an extension to cmd . It adds the functionality of the Gnu readline library to the Windows command line and so you can use all the Emacs-like editing commands that you can with bash : Control-a to move to the beginning of a line, Control-k to delete the rest of a line, etc.
Clink also gives you Windows-like behavior that Windows itself doesn’t provide, such as being able to paste text onto the command line with Control-v.
I’ve heard that Clink will work with PowerShell, but I was not able to make it work.
The command editing and history shortcuts beginning with ! mentioned above all work with Clink, as do substitutions like ^foo^bar .
Conclusion
In my opinion, the combination of Gow and Clink gives a good compromise between a Windows and Unix work environment. And if you’re running Windows, a compromise is probably what you want. Otherwise, simply run a (possibly virtual) Linux machine. Attempts to make Windows too Unix-like run down an uncanny valley where it’s easy to waste a lot of time.