.SH file extension
To open .SH files on Windows, to read it: open the .sh file in a text editor (for example, Notepad) to review the commands.
To open a .sh file, use a plain-text editor (for reading) or a terminal with a shell like sh/bash (for running). Do not treat it as a “document” format—.sh typically contains executable shell commands.
Last updated: June 11, 2026 · Reviewed by Julian Stricker
What “reviewed” means on this page
- Format fit: whether the “what is this file?” description matches common real-world use of the extension, including category, typical MIME types, and aliases.
- Opening paths: whether Windows / macOS / Linux steps read plausibly for current OS dialogs and default apps; we remove fantasy menus and unsafe shortcuts.
- Security framing: whether risk notes match the extension class (for example executables vs plain data) and whether affiliate wording does not contradict the security section.
- Sources and further reading: whether external links point to vendors, standards bodies, or other primary references where possible; we avoid inventing details we cannot ground.
- Limits: this is clarity and safety-messaging QA, not a guarantee that every statement is exhaustive or that every binary you download is harmless.
Full methodology in the Imprint — The Imprint also states where AI is used and what that does—and does not—replace.
Open on your device
Choose your operating system for a dedicated step-by-step opening guide.
How to open .SH files
Use these platform-specific instructions to open .SH files safely.
Windows
- To read it: open the .sh file in a text editor (for example, Notepad) to review the commands.
- 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).
- If you only need to inspect it, do not double-click to execute—treat it as code and review it first.
Mac
- To read it: open the .sh file with a plain-text editor to review its contents.
- To run it: open Terminal and execute with a shell (for example: sh /path/to/script.sh, or bash /path/to/script.sh).
- If it is meant to be executed directly, ensure it has the right interpreter line (shebang) and appropriate permissions before running.
Linux
- To read it: open the .sh file in a text editor to review commands.
- To run it: open a terminal and execute with sh (for example: sh ./script.sh) or bash if required by the script.
- If executing directly, ensure it is marked executable and that the script targets the correct interpreter (e.g., /bin/sh).
iOS
- iOS does not typically run .sh scripts as programs; open it as text for viewing, or transfer it to a Mac/Linux system to execute with sh/bash.
Android
- Android does not typically run .sh scripts in the default environment; open it with a text editor to read it, or move it to a desktop OS to run with sh/bash.
Security notes
- .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.
- Before executing, open the script in a text editor and read it—pay special attention to commands that download and run other code (for example, curl/wget piped to a shell) or that use sudo.
- Prefer running scripts in a controlled environment (for example, a dedicated user account or test system) when you did not author the script, and avoid granting elevated privileges unless necessary.
When a file can run commands or automation
Script and automation formats can perform powerful actions if they are allowed to run. Risk is highest from email attachments, chat links, and pirated bundles. Scan unfamiliar files and keep macro/script protections aligned with what you actually need.
Avast offers free and premium antivirus software that protects against viruses, malware, ransomware, and phishing. Scan files before opening them to ensure safety.
NortonNorton 360 delivers comprehensive antivirus protection, VPN, and identity theft monitoring. Scan files for threats before opening to keep your device secure.
We may earn a commission when you use affiliate links. This supports our free file extension guides.
Can't open this file?
These are the most common causes and fixes when .SH files fail to open.
Common reasons
- Double-clicking doesn’t run (or runs in the wrong context)
- “Permission denied” or not executable
- Script works on one system but fails on another
- Wrong file association / opens in the wrong app
Fix steps
- Run it from a terminal so you can see errors and control the environment (e.g., sh ./script.sh).
- 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.
- Open the script in a text editor to verify what it expects (paths, tools, environment variables).
OS-specific troubleshooting
What is a .SH file?
A .sh file most commonly contains a shell script: a text file of commands written in a shell command language and executed by a shell interpreter (often sh, and frequently bash). On Unix-like systems, scripts are commonly executed by invoking sh/bash with the file path, or via a shebang line (e.g., #!/bin/sh). Because it’s executable code, the practical difference between “opening” and “running” matters: viewing is safe, running may perform actions on your device.
Background
The .sh extension is widely used for shell scripts—text-based programs used to automate tasks such as installation steps, build/deploy pipelines, backups, and system configuration. The language and behavior are closely tied to the POSIX Shell Command Language and to common shells such as sh and bash.
On Linux and many Unix-like desktops, file managers often recognize .sh as a shell script via the shared MIME database, which helps decide icons and default apps. In MIME ecosystems you may see types such as text/x-sh and application/x-sh used in practice for .sh, but these are commonly “x-” (unregistered) conventions rather than official IANA-registered media types.
On Windows and mobile platforms, .sh files are typically treated as plain text rather than something you can run directly in the default environment. You can still read them in a text editor, but executing them usually requires a Unix-like shell environment (for example, a bash/sh environment) and should only be done when you understand what the script will do.
Common MIME types: text/x-sh
Further reading
Authoritative resources for more details on the .SH format.
Common .SH 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).
- Run it from a terminal so you can see errors and control the environment (e.g., sh ./script.sh).
- 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.
- 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.
- Try running via an interpreter: sh ./script.sh (or bash ./script.sh if it requires bash).
- Check that the script’s first line (shebang) points to a valid interpreter such as /bin/sh.
- 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.
- Check whether the script targets POSIX sh or bash; run it with the intended shell (sh vs bash).
- Review the script for shell-specific syntax and for required external commands that may not be installed.
- 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.
- Choose “Open With” and pick a plain-text editor for safe viewing.
- If you want to execute it, run it from a terminal with sh/bash instead of relying on file-manager actions.
- On Linux, file association behavior is influenced by the shared MIME database and desktop defaults; adjust your default app if needed.
FAQ
Is a .sh file a “document”?
Usually no. A .sh file is most commonly a shell script (a text program) meant to be interpreted by sh or a similar shell.
Can I open a .sh file in a text editor?
Yes. .sh files are plain text, so any text editor can open them for viewing and editing.
Why does it fail with sh but work with bash (or the other way around)?
Different shells support different features. Some scripts are written for POSIX sh, while others assume bash-specific syntax; run the script with the shell it was written for.
What MIME type is associated with .sh?
In practice, you may see unregistered “x-” types such as text/x-sh or application/x-sh used for .sh. These conventions are commonly found in MIME databases and /etc/mime.types files, but they are not necessarily IANA-registered media types.
Similar file extensions
Compare related formats in the same category to find the right tool faster.