Windows OS

How to Install and Use Linux Bash Shell on Windows 11

Linux is a customizable, stable, and secure open-source operating system. It supports bash, which is a default command-line interface for most of the GNU/Linux systems. The full bash form is “Bourne Again Shell”, as it was developed to replace Bourne Shell with additional features. The advantage of using a bash shell is it executes human-readable commands, executes programs, and handles file systems.

When using Windows, bash is a powerful tool to access Linux/UNIX commands and operations on Windows systems. You don’t have to install a virtual setup to run dual operating systems. Install WSL on Windows 11 and perform Linux commands and shell scripts within it.

How to Install & Use Linux Bash Shell on Windows 11

To access the bash shell on Windows 11, install WSL on the system. The process is quite simple & interesting, so there’s no need to worry.

Launch Windows Terminal by right-clicking on the Windows icon and selecting Terminal (Admin). This will run the terminal application as administrator:

After getting the terminal on screen, type in the following command to execute it and hit Enter:

wsl --install

The system will begin downloading and installing the relevant assets; this process may take several minutes.

After the wsl installation, the installation process will continue to start downloading Ubuntu automatically and ask you to restart the system once it’s done:

Next, the terminal will ask you to set credentials for the Linux default distro, Ubuntu. Ensure that you do not set the same Windows login Credentials; this should be different:

Once the process is completed, Ubuntu will be launched.

You’re not limited to Ubuntu distribution only. Other distributions can also be installed on Windows 11; just what distributions are available.

To see the list of available distributions, run the following command in Windows Terminal:

wsl --list --online

You can easily install any other Linux distro on Windows Terminal by referring to the list available and using the command given below:

wsl --install -d <distro_name>

Replace the destro_name with the name of the Linux distribution that you want to install:

wsl --install -d OracleLinux_9_1

The process is the same as we did in the Ubuntu installation; you need to add credentials that differ from Windows login credentials.

How to Launch Linux Distribution on Windows 11

You have two options to launch the downloaded Linux distribution:

Open the Windows Terminal through the Start menu and type the ubuntu command:

ubuntu

Alternatively, you can directly search it from the Windows Search bar by typing Ubuntu in it; select the Ubuntu app to launch it:

How to Run Bash Shell on Windows 11

Let’s run bash commands to check how it works to launch Linux Bash Shell on Windows 11.

To display the list of all Linux commands that can be used in Bash Shell, execute the following command in the terminal:

help -d

Run the help command with the parameter in Linux Bash Shell to get the individual command details:

help <parameter>

How to Create a Bash Script File in Windows 11

To create a bash file, the following process should be followed:

Step 1: Open a text editor like Nano or any other tool to create a file:

nano

Step 2: Start writing the script:

#! /bin/sh

echo “Hello World”

Save the file with the .sh extension by pressing the Control +X key and setting the file’s name like mybash.sh.

Step 3: Open the Linux terminal and type the ls command to check if the file has been successfully created:

How to Run Bash Script file in Windows 11

To run bash scripting, launch the command prompt on the screen and enable Linux distro by typing ubuntu in it.

Type the file name in the terminal and hit the Enter button:

bash mybash.sh

Conclusion

Linux Bash Shell is the default command-line tool and a replacement for Bourne Shell. It is a powerful tool to run Unix operations on Windows without installing a virtual setup. Bash shell supports user-friendly commands; not only this, but you can also execute Unix tasks and manipulate files within it. To get it on Windows 11, we must install WSL first on Windows 11, and it will automatically download Ubuntu as the default distro of Linux. This article mentioned a detailed guideline for installing WSL on Windows 11 and how to launch it. Moreover, we have learned how to run a bash script file on Windows 11.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.