Bash (Bourne Again SHell) is definitely a technology that will stay for years to come its simplicity and multi-platoformness is a factor that will definitely continue for many years thus even though it is mostly used on Linux / BSD / Unix, its application on Windows OS-es nowadays is perhaps increasing. Hence since so many people use Winodws nowdays (for work) it is really useful to have Bash set-up on Windows host machine.
In this article, I'll shortly explain how this is done, the article will not have anything too much interesting for the advanced admin or dev ops guy, but I hope people who are entering the business of system administration and high level computing and still orienting might benefit from it.
To install and use Bash shell terminal in Windows there are at least 3 ways:
- Use Git Bash (Download and install it directly precompiled on WIndows)
- Use Windows WSL emulation (install some Linux distro)
- Use Virtualbox / Vagrant / VMware / Hyper-V emulation and install VM from public ISO image.
As a Free Software Lover, I would recommend and always prefer to use the Free Software alternative if that is possible and thanksfully usually I use and install Git Bash or completely install Cygwin (Full set of Linux tools to run like native on Windows together with Mobaxterm) together.
1. Installing Git Bash on Windows (uses MinGW Minimalist GNU for Windows)
Some might prefer to not use Microsoft for managing their bash especially the more freedom in mind people who like GNU and Free software and people.
MinGW is well known among free and open source enthusiasts.
It includes a port of the GNU Compiler Collection (GCC), GNU Binutils for Windows (assembler, linker, archive manager), a set of freely distributable Windows specific header files and static import libraries which enable the use of the Windows API, a Windows native build of the GNU Project's GNU Debugger, and miscellaneous utilities.
MinGW does not rely on third-party C runtime dynamic-link library (DLL) files, and because the runtime libraries are not distributed using the GNU General Public License (GPL), it is not necessary to distribute the source code with the programs produced, unless a GPL library is used elsewhere in the program.
MinGW can be run either on the native Microsoft Windows platform, cross-hosted on Linux (or other Unix), or "cross-native" on Cygwin.
To install Bash via Git, you can use Git for Windows, which includes Git Bash — a lightweight Bash emulator.
Steps to Install Git Bash on Windows
a. Download Git for Windows
Go to the official Git website:
https://git-scm.com/download/win
The download should start automatically.
b. Run the Installer
- Open the downloaded .exe file
- Follow the installation prompts
Recommended Settings:
- Select components: Keep default
- Editor: Choose your preferred text editor (e.g., Notepad++ or Vim)
- Adjust PATH environment: Choose “Git from the command line and also from 3rd-party software”
- Choose SSH executable: Use Built-in OpenSSH
- Choose HTTPS transport backend: Use the default (OpenSSL)
- Configure line endings: Select “Checkout Windows-style, commit Unix-style line endings”
- Terminal emulator: Choose “Use MinTTY (the default terminal)”
Click Next through the remaining steps and then Install.
c. Launch Git Bash
After installation:
- Press Windows key, type "Git Bash"
- Click to launch the terminal
Now you're using a Bash shell on Windows.
Perhaps most common way is to use Windows Subsystem for Linux (WSL), people follow. WSL is a technology which is native Windows but gives MS Windows the opportunity to act in a way similar to docker containers. WSL lets you run a full Linux environment (including Bash) directly on Windows without using a virtual machine and is really fast and easy on Machine system resources.
2. Installing WSL bash easy from Windows 10 / 11 using Win GUI menus
Steps to install WSL on Windows 10 / 11
Microsoft has since only continued to improve its Windows Subsystem for Linux, and an update in a Windows 10 preview build back in mid-2020 made it easier to install Bash.
That method also works the same as on Win 10 as well as on Win 11.
To install Bash shell emulation, hence open Windows Terminal as an admin user. You can do this by right-clicking the Windows icon and selecting “Windows Terminal (Admin)” from the power user menu.
(If you’re on Windows 10, you should see it listed as “Windows Powershell (Admin)” in the menu.)
To complete WSL install with Virtualized Ubuntu OS
In Windows Terminal, run this command:
PS C:\Users\MyUser> wsl –install
Once everything is downloaded needed to run WSL emulation and Ubuntu Linux distribution, Restart the PC.
Once your PC rebooted, installation will continue automatically.
After Ubuntu installed successfully, you’ll next be prompted to create a username and password and Ubuntu will fire up, and you will have your bash in Windows
a. Enabling and Intalling BASH via command line (if WSL Linux subsystem for Windows is not enabled on Windows
It might be your Windows has no configured Windows Subsystem for Linux, hence if that is the case you will need to enable it following below few steps.
b. Enable WSL via dism.exe cmd
Open PowerShell as Administrator and run:
Powershell
PS C:\Users\MyUser> wsl –install
This installs WSL 2 and a default Linux distribution (like Ubuntu).
If you're on Windows 10 or on a PC where whoever installed the OS has not installed the Win Subsystem for Linux, you may need to manually enable WSL:
Launch Powershell
PS C:\Users\MyUser> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
PS C:\Users\MyUser> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Then restart your computer and run:
from the Windows Magnifier run Powershell and type in PS1 prompt:
PS C:\Users\MyUser> wsl –set-default-version 2
c. Installing other Linux Distribution (different from Ubuntu)
If not already installed during wsl –install, open the Microsoft Store and search for:
- Ubuntu
- Debian
- Kali Linux
- etc.
Click Install on the one you want.
d. Launching WSL / Bash terminal
Once installed:
- Open Start Menu
- Search for your Linux distro you just installed (e.g., “Ubuntu”)
- Launch it
This opens a Bash shell where you can run Linux commands, like in regular Linux but on your Microsoft Windows OS.
Sum it up
What we learned is how to install bash via Bash Git and start using it to have more hybrid environment Windows / Linux. The article explained the two main methods using GIt Bash and using embedded Windows emulator WSL with an emulated Linux distro.
Enjoy ! 🙂