
Step-by-Step Guide to Running Shell (.sh) Files on Windows OS
Running shell (.sh) files is a straightforward task on Unix-based systems like Linux and macOS, but on Windows, it requires a few additional steps. A shell script is a text file containing a sequence of commands meant to be executed by the shell. If you’ve come across a .sh file and you’re using Windows, don’t worry — you can still run it! This guide will walk you through how to do just that using various tools and methods that make working with .sh files on Windows both possible and convenient.
Contents
What Is a Shell (.sh) File?
A shell script or .sh file typically contains a series of Bash commands. These scripts are especially common in DevOps workflows, software development environments, and system automation. They are widely used for tasks like:
- Setting up development environments
- Managing files and directories
- Automating repetitive command-line tasks
Since Windows doesn’t natively come with a Bash shell interpreter, you’ll need a compatible environment that can run these scripts. Below is a step-by-step guide to doing just that.
Step 1: Choose Your Execution Environment
There are multiple ways to run .sh files on Windows. Here are the most popular options:
- Windows Subsystem for Linux (WSL) – Allows you to run a genuine Linux distribution alongside your Windows system.
- Git Bash – A lightweight Bash emulation environment bundled with Git for Windows.
- Cygwin – A more comprehensive but heavier Unix compatibility layer for Windows.
We recommend using WSL for most users, as it offers the best compatibility and performance.
Step 2: Install Windows Subsystem for Linux (WSL)
Follow these instructions to set up WSL:
- Open PowerShell as Administrator.
- Run the following command:
wsl --install
- Restart your computer when prompted.
- Upon reboot, choose a Linux distribution (like Ubuntu) and follow the on-screen prompts to complete the installation.

Step 3: Accessing Your .sh File
Once WSL is installed, you can access your file system, including your .sh file, using the WSL terminal. To do this:
- Launch the installed Linux distribution (e.g., Ubuntu) from the Start Menu.
- Navigate to the file location using
cd
. If the file is on your Windows drive, use the mount path:cd /mnt/c/Users/YourUsername/Downloads
Make sure your shell script is executable by running:
chmod +x filename.sh
Step 4: Run the Shell Script
With the script file now executable, run it with the following command:
./filename.sh
That’s it! Your shell script should now execute within your WSL environment just like it would on a native Linux system.
Alternative Method: Using Git Bash
If you’d prefer a lighter and simpler tool without installing a full Linux environment, Git Bash is a great choice.
- Download Git for Windows from the official site.
- Install it with default options and launch Git Bash.
- Navigate to the folder containing your .sh file using the
cd
command. - Make the script executable (if needed) and run it:
./filename.sh

Tips and Troubleshooting
- Line Endings: Windows uses different line endings (CRLF) than Linux (LF). If you encounter issues, convert the line endings in a code editor like VS Code.
- Script Permissions: If your script won’t run, double-check executable permissions using
chmod
. - Dependencies: If your script uses software packages, make sure they are installed in your WSL environment or Git Bash session.
Conclusion
Although Windows doesn’t natively support Bash shell scripts, there are efficient and practical ways to run them with minimal setup. Whether you choose WSL for its full Linux compatibility or Git Bash for quick scripting, you’ll be able to harness the power of shell scripting right from your Windows machine.
By learning to run .sh files on Windows, you’re opening the door to countless automation and development workflows. Give it a try—you might find it hard to go back!