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. With the Windows 10th anniversary upgrade of 2016, 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 11 version 22H2 and build 22621.819. You might need to update your Windows installation if you have 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 a complete Linux system inside Windows 10/11.
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 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.
Check for System Compatibility
You must be running specific versions of Windows for the different features described in this article. Requirements necessary for a particular feature to work are described under its own titles. To check your Windows version, search for about in the start menu.
Here, you can see the build of your PC as shown in the screenshot below. Make sure it is matching with the respective requirements described under various sub-headings here in this article.
- You must be running Windows 10 version 1607 (the Anniversary update) or above.
- WSL only runs on 64-bit versions 32-bit versions are not supported.
Install Bash in Newer Windows 10 and 11
Good thing is that the latest set of upgrades, including the stable release of WSL v1.0 released from Windows, makes it easier to install Bash on Windows. 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 the same for both distributions.
Step 1: Install WSL and the default distribution
In WSL, the default distribution is Ubuntu (which can be changed). In order to install, open Powershell as an administrator.
For this, search for Powershell in the start menu and right-click on Powershell, and select Run as Administrator.
Inside Powershell, enter the following command to install WSL, along with all necessary features and the default distribution, that is Ubuntu.
wsl --install
Once finished downloading and installing, you need to reboot to apply the changes.
Step 2: Configure the newly installed Ubuntu
After rebooting, search for Ubuntu in Start Menu and open it.
It will ask you to enter a UNIX Username and Password. Enter these details and press enter key.
You will now be inside the terminal window of Ubuntu.
Once logged in, you need to update the installed Ubuntu. For this, enter the following commands one by one:
sudo apt update
sudo apt full-upgrade
After completing the update, you are good to go with Ubuntu in WSL.
Install Bash on Older Windows
If you have the minimum requirements as mentioned in the beginning, but you’re running an older build of Windows, the previous method may not be supported. So there is a manual installation method.
Also, there are both WSL1 and WSL2 available. WSL2 offers some upgraded functionalities, but has some minimum requirements to run:
- For x64 systems: Version 1903 or later, with Build 18362 or later.
- For ARM64 systems: Version 2004 or later, with Build 19041 or later.
So this brings us to two possibilities to install:
Install Ubuntu with WSL 1
This is rather a simple procedure for those who have a system incompatible with WSL2. First, you need to enable the Windows Subsystem for Linux feature. This can be done through the command line. Open Powershell as an administrator and enter the following command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Or to do this via GUI, search for Windows Features in Start Menu.
Inside this, turn on Windows Subsystem for Linux feature.
You need to reboot your system after this step.
Once the reboot is completed, open the Windows store and search for the distribution of your choice.
Press get to install the distribution, Ubuntu in this case.
Once installation is completed, open the Ubuntu app from the start menu. It will take a couple of seconds to install. You will be prompted to enter a username and password. Provide those credentials and you are good to go with Ubuntu in WSL1.
Install Ubuntu with WSL 2
It is recommended to use WSL2 instead of WSL1 if you have support. In order to install Ubuntu with WSL2, you need to make sure that the WIndows Subsystem for Linux feature is turned on. For this, as in the above case, execute the following command in an elevated Powershell:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Reboot the device once the command is completed.
After this, you need to enable the Virtual Machine Platform feature. Open the Powershell with admin privileges and enter the following command:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Once again restart the device to complete the WSL install and update to WSL 2.
Now, download the Linux Kernel Update Package for x64 machines from the official website. If you are using ARM64 devices, use this link to download the latest kernel update package.
If you are not sure about the device architecture, enter the command below in Powershell to get the type:
systeminfo | find "System Type"
When the file is downloaded, double-click on it and finish the installation of the Kernel update package.
Now, open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:
wsl --set-default-version 2
Once WSL2 is set as the default version, now you can install the Linux distribution of your choice.
Go to Windows Store and install Ubuntu, as described in the earlier steps. and the rest of the procedure is already described above.
Enjoy Linux inside Windows.
Troubleshooting some common errors
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 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 this guide. You can do that even after you have installed Linux.
Troubleshooting 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.
On Windows 10, go to Settings -> Storage -> More Storage Settings: Change where new content is saved and select C Drive here.
On Windows 11, go to Settings -> System -> Storage -> Advanced storage settings -> Where new content is saved and select C Drive here.
Troubleshooting 3: Failed to attach disk Error
In some cases, while we reinstall the Ubuntu in WSL, this kind of error will appear.
In this case, open Powershell and run the following command:
wsl -l -v
This will list the installed Linux systems. Find the name of the system, that is throwing the error, in my case Ubuntu. Now run the following command:
wsl --unregister Ubuntu
You can restart the ubuntu app and it will run without any issues.
You can refer to more common troubleshooting methods from the official website.
Run GUI Apps On Windows Subsystem for Linux
The ability to run GUI apps on Windows Subsystem for Linux was introduced with the WSL 2 release in May 2020.
Windows Subsystem for Linux (WSL) with WSL2 now supports running Linux GUI applications (X11 and Wayland) on Windows in a fully integrated desktop experience. This allows you to install Linux applications and seamlessly integrate them into Windows desktop, including features like “pin to taskbar”.
One important point to note is that you will need to be on Windows 10 Build 19044+ or Windows 11 to access this feature.
Step 1: Enable/Update WSL 2
This procedure has been explained in the above section and you can refer to it.
Step 2: Download and Install Graphics drivers
In order to run GUI apps, you need to install appropriate graphics drivers. You can use the following link to download the drivers according to your provider.
Once installed, you are all done.
Step 3: Install some GUI Apps
Now, go to your Ubuntu app and install any GUI app using the APT package manager. You should note that running apps from other sources like flatpak are problematic within WSL.
For this article, I installed the Gedit text editor using the following command:
sudo apt install gedit -y
This will install several MB of packages including required libraries. Once completed, you can run the following command to start the GUI Gedit app in Windows.:
gedit
Similarly, you can install all the popular applications available to Linux, including Nautilus file manager, GIMP, etc. For more about running GUI applications in WSL, you can refer to the official documentation.
Install Linux Bash Shell on other 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.
Press Windows Key + I to access Windows system settings. Here, go to Update & Security:
From the left side pane, choose “For developers.” You’ll see an option for “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 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.
Once this is done, go back to the Start menu and search for Ubuntu or Bash.
Now you have 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 for installing bash on Windows and experimenting with Linux GUI apps on Windows. No wonder WSL lets you play with Linux inside of Windows. If you have questions or suggestions, feel free to ask.