How to Run .sh File in Windows – Linux Hint

The “sh” file is a scripting script file with a “.sh” extension. Contains system programs that can run on the Unix-based system or in the UNIX shell. A sh file can be opened in many text editors like notepad, Apple terminal. However, this scripting file is typically run on the command line using the “bash” or “sh” command.

The following article will show the method to run a .sh file in Windows.

How to configure WSL in Windows?

The .sh file cannot be run directly at the Windows command prompt or PowerShell. Therefore, to run the .sh file on Windows, it is necessary to enable “Windows Subsystem for Linux” (WSL) on the system.

Follow the steps provided below to enable WSL on Windows system.

Step 1: Turn on developer mode In the first step, open the Windows “Settings” by looking for it in the “Start” menu

: How to Run .sh File in Windows 1

Go to the “Update & Security” settings:

<img src="" alt="

” /> Open the “

For developers” window and activate the “Developer mode


<img src="" alt=



Step 2: Enable WSL

in Windows When typing “Windows Features”

in the search field, select the “Turn Windows features on or off” option:

How to Run .sh File in Windows 4

When you do this, the “Windows Features” wizard will appear on the screen. Check the “Windows Subsystem for Linux” checkbox and press the

“OK” button: How to Run .sh File in Windows 5

This operation will start enabling WSL in Windows:

<img src="" alt=""


Then restart the system for the changes to take effect by pressing the “Restart Now” button:

How to Run .sh File in Windows 7

At this point, we have enabled WSL in Windows. We will now install Linux-compatible tools that help us execute Linux commands on Windows.

Step 3: Install Ubuntu


Tool Go to the “Microsoft Store” by searching for it in the “Start” menu:

How to Run .sh File in Windows 8

Search for “Linux application” in the search bar. Scroll down, select

and open Ubuntu 22.04 LTS: How to Run .sh File in Windows 9 Click the “Get” button to install Ubuntu 22.04 LTS terminal on Windows:

<img src

=”” alt=””


Press the “Open” button to open and configure Ubuntu 22.04 LTS on Windows:

How to Run .sh File in Windows 11

Step 4: Configure the initial setup of


The Ubuntu terminal will open on the screen. Set the username and password:

How to Run .sh File in Windows 12

The output given above shows that we have correctly configured WSL in Windows. Let’s go ahead to create a .sh file.

How to create a .sh file in Windows?

To create a .sh file in Windows by using the command line, follow the steps provided

: Step

1: Open Windows Command Prompt

Search for “CMD” in the “Start” menu and open the command prompt


How to Run .sh File in Windows 13

Step 2: Enable

the Linux

command line interface Enable the Linux command line interface by using the “bash” command. Then, switch to the “Documents” directory for file creation. You can also

create a .sh file in the currently open directory: How to Run .sh File in Windows 14

Step 3: Create .sh file Now, we will create a .sh file called “” file with the help of nano editor:

<img src


alt=”” />

Paste the code provided below into the open file, press “Ctrl + O” to save the file and exit the nano editor by pressing “Ctrl + X“:

How to Run .sh File in Windows 16

We have created a file using the Windows command prompt. Let’s take a look at the method to run the .sh file.

How to run .sh file in Windows?

To run a .sh file in Windows, use the “bash” command and specify the name of the file. We will run our “” file using the following command


The output given below indicates that we have successfully

run the .sh file on Windows:

How to Run .sh File in Windows 17

We have compiled the approaches to allow WSL to create and run the .sh file in Windows.

Conclusion To run the .sh file on Windows, you need to enable the WSL feature. After enabling WSL, download the tool that supports Linux command line, as we have downloaded the “Ubuntu 22.04 LTS” on Windows. Then, create a .sh file and run it using the “$bash” command in the command prompt. We have demonstrated the method to create and run .sh files on Windows using WSL.

Contact US