How to open .SH files on Windows

To open .SH files on Windows, to read it: open the .sh file in a text editor (for example, Notepad) to review the commands.

Step-by-step instructions

  1. To read it: open the .sh file in a text editor (for example, Notepad) to review the commands.
  2. To run it: use a Unix-like shell environment that provides sh/bash, then execute it from that environment (for example: sh path\to\script.sh).
  3. If you only need to inspect it, do not double-click to execute—treat it as code and review it first.

Common issues

Double-clicking doesn’t run (or runs in the wrong context)

On many systems a .sh file is just a text file association, and on Windows it generally won’t run without a Unix-like shell environment. Even on Unix-like systems, running by double-click can behave differently than running in a terminal (different working directory, environment variables, permissions).

  1. Run it from a terminal so you can see errors and control the environment (e.g., sh ./script.sh).
  2. If you’re on Windows, use an environment that provides sh/bash; otherwise, treat it as a text file and run it on macOS/Linux.
  3. Open the script in a text editor to verify what it expects (paths, tools, environment variables).

“Permission denied” or not executable

On Unix-like systems, scripts may lack execute permission, or execution may be blocked by policy. You can still run it by explicitly invoking the interpreter (sh/bash) even if it’s not marked executable.

  1. Try running via an interpreter: sh ./script.sh (or bash ./script.sh if it requires bash).
  2. Check that the script’s first line (shebang) points to a valid interpreter such as /bin/sh.
  3. If you do choose to execute directly, ensure permissions and ownership are correct for your workflow.

Script works on one system but fails on another

.sh scripts may rely on non-POSIX shell features or external utilities that differ between systems. A script written for bash may fail if run with a strictly POSIX sh, and vice versa.

  1. Check whether the script targets POSIX sh or bash; run it with the intended shell (sh vs bash).
  2. Review the script for shell-specific syntax and for required external commands that may not be installed.
  3. If portability is required, align the script with the POSIX Shell Command Language and test on the target platform.

Wrong file association / opens in the wrong app

Desktop environments use MIME mappings and file associations; a .sh file may open in an editor, a terminal, or something unexpected depending on your defaults.

  1. Choose “Open With” and pick a plain-text editor for safe viewing.
  2. If you want to execute it, run it from a terminal with sh/bash instead of relying on file-manager actions.
  3. On Linux, file association behavior is influenced by the shared MIME database and desktop defaults; adjust your default app if needed.

Security note

.sh files are executable scripts: running one can install software, modify files, exfiltrate data, or change system settings. Only run scripts from sources you trust and understand.

Back to .SH extension page