- Use bash shell in windows
- 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
- About Abhishek Prakash
- How to Enable the Linux Bash Shell in Windows 10
Use bash shell in windows
Bash has been one of the most well-known feature of Linux distributions, which due to its flexibility as well as ease of usage, made it popular among programmers. The Windows’ operating system’s command line interface, cmd.exe, on the other hand, lacked various capabilities of it’s Linux counterpart.
Microsoft, therefore, in their Anniversary Update, added several features to the Windows 10 OS, with bash being one of them. To install and use it on Windows 10, one need to perform the following steps :
- Start -> Settings -> Update&Security. Under the ‘Use Developer Features’, select ‘Developer mode’.
Selecting the developer mode will pop the following alert. Click yes, and let the computer restart.
Go to Control Panel -> Programs and Features -> Turn Windows Features On and Off. In the window that appears, check the ‘Windows Subsystem for Linux’ option, and click OK.
This will trigger an alert asking for the system to be restarted to complete the installation of the required components. After the restart is complete, go to the command prompt, and type ‘bash’. Follow the instructions that appear to install bash from Windows store. After it is installed, it will be required to create a UNIX username. After completing the installation, exit the prompt.
To access the shell, simply type ‘bash’ in the Windows command prompt, and everything is good to go.
Note that bash runs natively on Windows 10, which is different from using emulators like ‘cygwin’ for Windows which enabled GNU tools to run on unsupported Windows environment. Also, Linux subsystem for Windows 10 is only available on the 64-bit version of the OS.
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.
About Abhishek Prakash
Creator of It’s FOSS. An ardent Linux user & open source promoter. Huge fan of classic detective mysteries ranging from Agatha Christie and Sherlock Holmes to Detective Columbo & Ellery Queen. Also a movie buff with a soft corner for film noir.
How to Enable the Linux Bash Shell in Windows 10
Linux geeks rejoice. As of build number 14328, Windows 10 allows you to run a special flavor of the Bash shell (on Ubuntu) in a window. Using Bash, you can navigate around the file system, install and run Linux command line apps like the vi text editor or, with some unofficial tweaks, try to load windowed programs. However, before you can use Bash in Windows 10, you have to turn it on. Here’s how.
1. Navigate to Settings. You can get there by clicking the gear icon on the Start menu.
2. Click Update & security.
3. Select For Developers in the left column.
4. Select Developer Mode under «Use developer features» if it’s not already enabled.
5. Navigate to the Control Panel (the old Windows control panel). You can get there by hitting Windows Key + X and selecting Control panel from the pop-up menu that appears.
6. Select Programs and Features. If it’s not visible, make sure you select «Large icons» from the «View by» menu.
7. Click «Turn Windows features on or off.»
8. Toggle «Windows Subsystem for Linux» to on and click Ok.
9. Click the Restart Now button.
10. Search for Bash in the Cortana / Search box and click its icon.
11. Type «y» and hit Enter when promoted to install Ubuntu. The system will then take a few minutes to install Ubuntu in the command prompt window.
12. Create a username and password.
You can now use the Bash shell as if you were on a a computer with Ubuntu installed as its primary OS. There are a few command line apps built-in, including the vi and pico text editors, and you can add more by using the apt-get command. There’s also a program which allows you to run windowed Ubuntu apps in Windows 10.