.SH

SH File

Shell Script
Ask a question
QUICK ANSWER

A .sh file is a plain-text shell script containing Unix/Linux commands. To read it, open it in any text editor. To run it on Linux or macOS, use "chmod +x script.sh && ./script.sh" or "bash script.sh". On Windows, it does not run natively - use WSL or Git Bash. Scripts from untrusted sources can be dangerous; read them before running.

Developer: Bourne shell (Stephen Bourne, Bell Labs, 1979); Bash (GNU) Category: Developer Files Open standard MIME: application/x-sh
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jun 16, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the SH file format?

.sh is a common Unix shell file extension, used by bash (Bourne-again shell) and other POSIX-compatible shells. .sh files store shell scripts - sequences of commands and instructions written in shell language, saved as plain text.

.sh files are created in any text editor and are mainly used for scripts executed by a Unix shell command line. A .sh file typically begins with a shebang line - such as #!/bin/sh or #!/bin/bash - which tells the operating system which interpreter to invoke. To run a script directly, the file must be made executable with chmod +x filename.sh.

Bash is an interpreted command language and a free Unix shell distributed under the GNU license, used by default on many Linux and macOS systems. Most Unix-family systems support this shell. Bash replaced the original Bourne shell, hence the name - Bourne-again.

.sh files can also be used for saving scripts intended for other shells, such as Korn Shell, Z Shell, C Shell, or Bourne Shell. On Windows, equivalent automation is handled by batch files or PowerShell scripts. Because .sh conventionally signals POSIX shell compatibility, scripts targeting a specific shell declare their interpreter explicitly in the shebang line.

Security & safety

RISK: MEDIUM

A .sh file is the Unix equivalent of running arbitrary commands: when executed it can do anything the user can - delete files, install software, exfiltrate data, or run malware. The notorious "curl URL | bash" pattern runs a remote script with no chance to inspect it. Safety rules: (1) NEVER run a .sh from an untrusted source without reading it first - it's plain text, so open it in an editor and check what it does; (2) be wary of obfuscated one-liners, base64 blobs, or scripts that pipe to sudo; (3) self-extracting installer scripts (shar/Makeself, including .run) hide a payload after the script - only run them from the official vendor. A .sh is not automatically dangerous, but it is code, so trust the source.

Format details

in a nutshell
FULL NAMEShell Script
DEVELOPERBourne shell (Stephen Bourne, Bell Labs, 1979); Bash (GNU)since 1979 (Bourne shell, Unix V7); POSIX shell standardized; Bash 1989
MIME TYPEapplication/x-sh
TYPEPlain-text Unix shell script (executable text)
STANDARDOpen · royalty-free

Programs that open SH files

Windows4 apps
Cygwin Open-source POSIX environment for Windows; run scripts in the Cygwin terminal. WSL is the modern alternative.
WSL (Windows Subsystem for Linux) Built-in Install with 'wsl --install', then run 'bash script.sh' inside the Linux environment - the most faithful way to run .sh on Windows.
Git Bash Open-source Comes with Git for Windows; right-click in a folder > 'Git Bash Here', then 'bash script.sh'. Good for simple scripts.
Notepad / VS Code Open-source Open the .sh to READ/edit it as text. (Editing only - Windows can't execute it without WSL/Git Bash/Cygwin.)
macOS2 apps
Terminal (zsh/bash) Built-in Run: chmod +x script.sh && ./script.sh, or 'bash script.sh'. macOS ships Bash 3.2 plus zsh as the default shell.
BBEdit / VS Code Free Open the .sh to read/edit with syntax highlighting before running it.
Linux2 apps
Bash (built-in) Open-source Make it executable then run: chmod +x script.sh && ./script.sh - or run directly: bash script.sh
Any text editor (gedit, nano, vim) Open-source Open the .sh to READ/edit it - it's plain text. Always inspect an unfamiliar script before running.

Technical details

deep spec
File typePlain-text executable shell script
MIME typeapplication/x-sh
Shebang conventionFirst line declares interpreter: #!/bin/sh, #!/bin/bash, or #!/usr/bin/env bash
Character encodingUTF-8 or ASCII; encoding must be supported by the target shell
Line endingsLF (Unix-style) required; CRLF line endings cause syntax errors on most shells
Execution methodInvoke with bash script.sh, or set executable bit (chmod +x) and run directly as ./script.sh
Comment syntax# character; everything from # to end of line is ignored by the interpreter
Variable assignmentNo type declaration required; VAR=value (no spaces around =); accessed as $VAR or ${VAR}
Exit code convention0 = success; any non-zero value = error; returned via exit N or inspected in $?
POSIX portabilityScripts written to POSIX sh standard run on bash, dash, ksh, and any conforming shell
Error handling flagsset -e exits on first error; set -u treats unset variables as errors; set -o pipefail catches pipe failures
Platform supportNative on Linux and macOS; available on Windows via WSL, Git Bash, or Cygwin
Primary interpreterBash (GNU Bourne-Again Shell); also dash, ksh, or zsh depending on the shebang line
Script debuggingset -x enables trace mode, printing each command before execution; bash -n checks syntax without running
Released1979 (Bourne shell, Unix V7); POSIX shell standardized; Bash 1989
Open standardYes · royalty-free
Specificationpubs.opengroup.org

SH conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with SH files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about SH files.

Frequently asked questions

How do I run a .sh file on Linux or Mac?
Open a terminal, give it execute permission with 'chmod +x script.sh', then run './script.sh'. Or run it without changing permissions using 'bash script.sh' (or 'sh script.sh').
How do I run a .sh file on Windows?
Windows can't run shell scripts natively. Install WSL ('wsl --install') and run 'bash script.sh', use Git Bash that comes with Git for Windows, or use Cygwin. To only read/edit the script, open it in Notepad++ or VS Code.
Why do I get 'Permission denied' when running a .sh file?
The file isn't marked executable. Run 'chmod +x script.sh' first, then './script.sh'. Alternatively run it via the interpreter directly: 'bash script.sh', which doesn't need the execute bit.
How do I see what a .sh script does before running it?
It's plain text - open it in any editor (Vim, nano, VS Code, Notepad++). Read it top to bottom; be suspicious of obfuscated commands, remote downloads piped to a shell, or unexpected sudo. Don't run scripts you don't understand from untrusted sources.
What's the difference between sh and bash?
sh is the original Bourne/POSIX shell; bash (Bourne-Again Shell) is a superset with extra features (arrays, [[ ]] tests, more string handling). A script with '#!/bin/bash' may fail under strict '#!/bin/sh' if it uses bash-only syntax.
Is it safe to open a .sh file?
Reading/editing it is completely safe (it's text). RUNNING it is what carries risk - a script executes whatever commands it contains. Only run .sh files from sources you trust, and read unfamiliar ones first.

References

1GNU - Bash reference manualwww.gnu.org
2Microsoft - Windows Subsystem for Linuxlearn.microsoft.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.BINCD/DVD Disc Image (BIN/CUE)
3.MDMarkdown Document
4.PARTPartial Download File
5.RPMSGRestricted Permission Message
6.CRDOWNLOADChrome Partial Download File
7.NOMEDIAAndroid No-Media Marker File
8.PRDXSoftMaker Presentations Document
9.SWFSmall Web Format (Shockwave Flash)
10.PRO6XProPresenter 6 Bundle File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z