Shell scripts or . SH files are like Windows batch files that can run on Linux or Unix. It is possible to run .sh or Shell Script file on Windows 10 using the Windows Subsystem for Linux. In this post, we will show you how to run a Shell Script file on Windows 11/10.
How to run .sh or Shell Script file in Windows 11/10
Bash is a Unix shell and command language that can run Shell Script files. You don’t need to install Ubuntu or any other Linux distribution unless your scripts need actual Linux kernel support. We will share both methods.
Run shell script file using WSL Run shell script using
- Ubuntu on Windows 10 1] Run shell script file using
WSL Install WSL
or Windows subsystem for Linux
Update and Security Settings > > for developers. Check the Developer Mode radio button. And find “Windows Features”, choose “Turn Windows Features on or off”.
Scroll to find WSL, select the check box, and then install it. Once done, one has to restart to finish installing the requested changes. Press Restart Now. BASH will be available at the command prompt and PowerShell.
shell script files
- Open the command prompt and navigate to the folder where the script file is available
- Type Bash script-filename.sh and press the Enter key
- You will run the script, and depending on the file, you should see an output.
On a Linux platform, you usually use SH, but here you need to use BASH. That said, BASH on Windows has its limitations, so if you want to run in a Linux environment, you need to install Ubuntu or something similar.
2] Run Shell Script using Ubuntu on Windows 11/10
Make sure you have Ubuntu or any other Linux distribution installed. Ubuntu will mount or make all your Windows directories available in /mnt. Therefore, drive C is available in /mnt/C. So, if the desktop will be available in /mnt/c/users/<username>/desktop.
Now follow these steps
- Bash at the run prompt and the distribution message will start
- cd” command to the folder where the scripts are available
- Type “sh script.sh” and press Enter.
. Navigate to the folder using the “
It will run the script, and if they have a dependency on any of the core features of
Since Linux is now available on Windows, you don’t need to use any third-party applications like Cygwin. WSL should be enough for most scenarios to help you run a shell script on Windows 11/10.
How do I create a . SH file?
The steps to create
a shell script file are: Create a file with
- an editor
- with #! /bin/sh
- Write the desired code
- To run the script type bash ABC.sh.
Script file name with .sh extension Start the script
Can shell scripts run on Windows?
Yes, now with Bash Shell in Windows
11 and Windows 10, you can now create and run Bash shell scripts and incorporate Bash commands into a Windows batch file or PowerShell script.