Tech

2 Ways to Install the Bash Shell on Windows

The interpreters of Command line they are something that is usually associated with Linux, however, their use has grown in Windows in recent times, mainly due to the momentum of PowerShell and especially WSL, which allows you to run a complete Linux operating system inside Windows. Seeing this trend, although it does not go beyond professionals, enthusiasts and curious, I am going to mention two ways to use bash inside Windows, but before I get into it, it’s better to explain a bit what Bash is.

Bash, which is an acronym for Bourne-again shellis the most widely used command interpreter among Linux distributions and it was also used by macOS, then OS X, for a long time, but Apple decided to replace it with Zsh when the license was changed from GPLv2 to GPLv3, since the latter is too restrictive for the likes of the company with the bitten apple . The person in charge of the development of Bash is the GNU project, which represents the materialization of the principles of free software and is in charge of many tools that are widely used within the spectrum of free software in general and Linux in particular.

The development of Bash began in 1988 and the following year the first version was released with the purpose of providing the GNU operating system with a competent command line interpreter adjusted to POSIX standards. However, the project choked on the development of its own kernel, which is a Hurd that has been de facto abandoned for a long time, so its place ended up being occupied by Linux, thus giving rise to what many define as GNU. /linux.

Looking at its track record, it’s obvious that Bash is a Unix-oriented and Unix-like shell, but that’s not to say that it can’t be used, not without certain “gotchas,” on Windows. While it is true that Microsoft did not hesitate to establish itself as the number one enemy of Linux and free software at the beginning of the century, circumstances have changed a lot since Satya Nadella became the CEO of the Redmond-based corporation.

WSL: the “least artificial” way to use Bash on Windows

WSL is Windows Subsystem for Linux and an environment or feature that allows you to run a full Linux operating system on top of Windows without the need for a separate virtual machine or dual boot. Its creation has the purpose of preventing developers from going from Windows to Linux, more seeing that the use of the second is prevailing in sectors such as artificial intelligence. On the other hand, WSL is considered by its detractors as an “adopt, extend and die” maneuver by Microsoft.

At the desktop level, WSL can be activated in Windows 10 and Windows 11and for that the user has to open the old “control Panel”, which can be found by entering its name in the Start menu search engine.

Old Windows Control Panel in the Start menu

Once the old Windows Control Panel has opened, you have to click on the section Programs.

Programs section of the old Windows Control Panel

After accessing the Programs section, click on “Turn Windows features on or off”, a section that can also be reached after accessing “Programs and features”.

Go to Turn Windows features on or off

After opening the window “Windows features” you have to scroll down until you locate “Windows subsystem for Linux”, which obviously has to be marked to then click on the Accept button. After finishing installing the feature, the system will ask to be rebooted to complete the process.

Activate Windows Subsystem for Linux (WSL)

Reboot request after finishing WSL installation

WSL is already installed, but now you have to introduce some Linux distribution to it. For this we will resort to the version of Ubuntu for the subsystem, which can be obtained from the Microsoft Store. When you have accessed the Ubuntu page/tab in the store, you just have to click on the Get button to start the download and installation. Once the process is complete, it is possible to start the Linux system by clicking on the Open button that should appear on the Microsoft Store page/tab or by searching for Ubuntu in the Start menu.

After starting Ubuntu, the user can check the version of bash entering the command echo "${BASH_VERSION}"which checks the version running on the system, or bash --version, which allows you to check your own installed version of Bash. From here it is possible to start learning to use the command interpreter, with which it is also possible to create programs using shell scripts or shellscripting.

Running Bash on Ubuntu with WSL

Git Bash shell for Windows, a way to use Bash without having to resort to WSL

Another way to get Bash to use on Windows is through Git for Windows, which provides a MING64 environment with access to the aforementioned shell. In addition to Git Bash, the installer also provides in its path the possibility to use OpenSSH, which is the well-known remote access tool developed mainly by OpenBSD, and the OpenSSL cryptographic library, which is widely used in Linux.

Obtaining Git Bash begins with downloading the Git for Windows installer. After that and as usual, you have to start it by double clicking on it.

Downloading Git for Wnidows to get Git Bash

As at general levels I have left things as they were by default, I will limit myself to exposing four steps that I have seen as important. For a start, I have selected “Git from command lines and also from third-party software” (Git from the command line and also from 3rd-party software) in the step of setting the user PATH environment (Adjusting your PATH environment). Here it is true that the first option, “Use Git only from Git Bash” (Use Git from Git Bash only), should suffice if you just want to tinker with the command line.

How to integrate Git into the system PATH, if only with Git Bash or also with CMD, PowerShell and third-party software

Another step that I have modified is the components, where I have selected additional icons (additional icons), check daily for Git for Windows updates (Check daily for Git for Windows updates) and add a Git Bash profile to Windows Terminal ((New!) Add a Git Bash Profile to Windows Terminal).

Additional Git Bash Components

In the extra options configuration step (Configuring extra options) I have selected to be enable symbolic links (Enable Symbolic links)while of the experimental options I have not marked anything.

After completing the installation process, git bash It will be available from the Windows Start menu. Once opened, the user will see that a MINGW64 environment is started with which they can run Bash commands.

Git Bash up and running

Conclusion

As we can see, there are several ways to use Bash in Windows, although currently the most natural is to use WSL. The subsystem, which was originally created with the purpose of executing command line tools, has evolved to be able to run graphical applications. If the user needs to deal with different interpreters at the same time, it wouldn’t hurt to resort to Windows Terminal.

Windows Terminal

While Bash is still the most popular shell on Linux, in recent times it has had to face competition from Zsh, which has been set by default on macOS thanks to being released under the permissive MIT license and being able to be used. on Windows via UnxUtils. There is also PowerShell, Microsoft’s powerful interpreter, which after the publication of its source code under the same MIT license has reached Linux and macOS, although Microsoft has saved several letters that are exclusive to Windows.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *