Windows can’t run .sh shell scripts on its own, because they’re written for Linux and macOS shells like Bash. The best way to run one is with the Windows Subsystem for Linux (WSL): install it once with wsl --install, then run bash script.sh from the Linux terminal. For simple scripts, Git Bash is a lighter option. Both methods work on Windows 11 and Windows 10.
Method 1: Run a .sh file with WSL (recommended)
Install WSL
- Right-click the Start button and choose Terminal (Admin) (on Windows 10, Windows PowerShell (Admin)).
- Run
wsl --install. - Restart the PC when asked.
- After the restart, a Linux (Ubuntu by default) window opens. Create a Linux user name and password when prompted.
For more detail, see how to install WSL on Windows 11.
Run the script
- Open Ubuntu (or your Linux distribution) from the Start menu.
- Go to the folder that contains the script. Your Windows drives are under
/mnt, so a script in your Downloads folder is at a path like/mnt/c/Users/YourName/Downloads. Usecdto move there. - Run
bash script.sh.
To run it as a program instead, make it executable once with chmod +x script.sh, then run ./script.sh.
Run it straight from PowerShell or Command Prompt
With WSL installed, open a terminal in the script’s folder and run wsl bash script.sh. WSL starts, runs the script in that folder, and returns you to Windows.
Method 2: Run a .sh file with Git Bash
- Download and install Git for Windows from git-scm.com. It includes Git Bash.
- Open the folder that contains the script in File Explorer.
- Right-click an empty area and choose Open Git Bash here (on Windows 11, select Show more options first).
- Run
bash script.shor./script.sh.
Git Bash handles common commands well, but it isn’t a full Linux system. Scripts that use apt, Linux services, or Linux-only programs need WSL.
Fix common errors
- “$’\r’: command not found” or “bad interpreter”: the script was saved with Windows line endings. In WSL, run
sed -i 's/\r$//' script.sh, or install and rundos2unix script.sh. In code editors like VS Code, switch the line ending from CRLF to LF and save. - “Permission denied”: run
chmod +x script.sh, or start it withbash script.shinstead of./script.sh. - “No such file or directory”: check the path with
ls. Linux paths are case-sensitive and use forward slashes. - A command in the script isn’t found: install the missing tool inside WSL, for example
sudo apt install curl. - WSL is stuck or acting strangely: run
wsl --shutdownin PowerShell and open it again. See how to reboot WSL.
Be careful with scripts from the internet
A shell script can delete files, change settings, or download other programs. Open it in a text editor and read it before running it, and only run scripts from sources you trust.
Frequently asked questions
Can I double-click a .sh file to run it?
Not by default. Windows doesn’t know which program to use. Running it from a WSL or Git Bash terminal is the reliable way.
What’s the Windows equivalent of a .sh file?
Batch files (.bat or .cmd) and PowerShell scripts (.ps1) do the same job natively on Windows, but the commands are different, so a .sh script can’t simply be renamed.
Do I need WSL 2?
wsl --install sets up WSL 2 by default on current Windows versions, which is what most people should use. See how to install WSL 2 on Windows 11.

Kermit Matthews is a freelance writer based in Philadelphia, Pennsylvania with more than a decade of experience writing technology guides. He has a Bachelor’s and Master’s degree in Computer Science and has spent much of his professional career in IT management.
He specializes in writing content about iPhones, Android devices, Microsoft Office, and many other popular applications and devices.