.COMMAND

COMMAND File

macOS Terminal Shell Script
Ask a question
QUICK ANSWER

A COMMAND file is a macOS shell script that opens and runs in Terminal when you double-click it in Finder. To run it, double-click the file - Terminal starts automatically. If macOS blocks it, right-click and choose Open. Read the script in a text editor before running any COMMAND file from an unknown source.

Developer: Apple Inc. Category: Executable Files Open standard MIME: text/x-shellscript
OPENS ON macOS
Related: .APK · .EXE · .VBS · .JAR

On this page

19k+ extensions indexed
Last reviewed Jul 30, 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 COMMAND file format?

A .command file is a plain-text shell script that macOS Finder is configured to open directly in Terminal.app and execute. In content it is identical to a shell script - a sequence of POSIX shell commands with an optional shebang line on the first line. The .command extension is what distinguishes behavior: double-clicking a .command file launches Terminal.app and runs the script in a new window, whereas double-clicking a .sh file opens it in a text editor.

Before a .command file can be run by double-clicking, it must have execute permission set - use chmod +x yourscript.command in Terminal. Files downloaded from the internet are subject to macOS Gatekeeper; right-click and choose Open to bypass the first-run warning for unsigned scripts.

Without a shebang, macOS defaults to /bin/sh. Common shebangs are:

  • #!/bin/bash - Bash interpreter
  • #!/bin/zsh - Zsh (macOS default shell since Catalina 10.15)
  • #!/bin/sh - POSIX sh (most portable)

.command files are widely used to ship simple macOS utilities, installers, and developer tools that need a Terminal session visible to the user. They open in any text editor and are fully human-readable.

Security & safety

RISK: MEDIUM

A .command file can execute any shell command on macOS - including deleting files, downloading malware, or modifying system settings. Never run a .command file from an untrusted source without reading its contents first (right-click > Open With > TextEdit). macOS Gatekeeper adds a quarantine flag to files downloaded from the internet, producing a warning on first run - do not bypass this for unknown scripts.

Format details

in a nutshell
FULL NAMEmacOS Terminal Shell Scriptaka .command file, Terminal command file
DEVELOPERApple Inc.since ~2001 (Mac OS X 10.0 - Terminal.app era)
MIME TYPEtext/x-shellscript
TYPEtext shell script (bash/zsh/sh)
STANDARDOpen · royalty-free

Programs that open COMMAND files

macOS5 apps
TextEdit Built-in Right-click the .command file > Open With > TextEdit to view/edit the script without running it.
MacVim Open-source Open in MacVim for syntax-highlighted editing: macvim script.command in Terminal.
Apple Terminal Built-in Double-click the .command file in Finder; Terminal opens and runs the script. Ensure execute permission: chmod +x script.command in Terminal first.
iTerm2 Open-source Set iTerm2 as default terminal; .command files will then open in iTerm2 instead of Terminal.
Visual Studio Code Open-source Right-click > Open With > Visual Studio Code for syntax-highlighted editing.

Technical details

deep spec
File typePlain-text POSIX shell script
MIME typetext/x-shellscript
EncodingUTF-8 (recommended); ASCII also common
Line endingsUnix-style LF required; Windows CRLF line endings break script execution
Magic bytesNone (plain text); shebang on line 1 identifies the interpreter
Execute permissionchmod +x required; without it Finder double-click does not launch Terminal
Default interpreter (no shebang)/bin/sh on macOS
Gatekeeper quarantineDownloaded .command files trigger first-run warning; right-click > Open to bypass
Finder double-click behaviorLaunches Terminal.app and runs the script in a new window
Functional difference from .shExtension only; script content identical - .sh opens in text editor, .command executes in Terminal
Associated OSmacOS (Finder integration); script syntax runs on any POSIX system
Typical file size100 bytes - 100 KB
Released~2001 (Mac OS X 10.0 - Terminal.app era)
Open standardYes · royalty-free
Specificationsupport.apple.com

COMMAND conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with COMMAND 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 COMMAND files.

Frequently asked questions

What is a .command file on Mac?
A shell script that opens and runs in Terminal when double-clicked in Finder. It is plain text, identical in content to a .sh script.
How do I run a .command file?
Double-click it in Finder - Terminal opens automatically. If macOS blocks it, right-click > Open. If you see 'permission denied', run chmod +x ~/path/to/script.command in Terminal first.
How do I open a .command file to read/edit it?
Right-click the file in Finder > Open With > TextEdit (or Visual Studio Code, MacVim). Do NOT double-click if you only want to read it.
Can I run a .command file on Linux or Windows?
Linux: rename to .sh and run in a Bash terminal. Windows: use WSL (Windows Subsystem for Linux) or Git Bash; the content is standard shell script.
Why does macOS say the .command file can't be opened because the developer can't be verified?
Gatekeeper blocked an unsigned script. If you trust the source, right-click > Open and confirm. Otherwise read the script contents first.
What is the difference between .command and .sh?
Only the Finder association: .command opens in Terminal when double-clicked; .sh opens in a text editor. The script syntax and content are identical.

References

1Apple Support - Intro to shell scripts in Terminal on Macsupport.apple.com
2ss64.com - Run a macOS shell scriptss64.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.MDMarkdown Document
4.BINCD/DVD Disc Image (BIN/CUE)
5.PARTPartial Download File
6.RPMSGRestricted Permission Message
7.NOMEDIAAndroid No-Media Marker File
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.ICSiCalendar data file

Related extensions

.APKAndroid Package
.EXEWindows Executable (Portable Executable)
.VBSVBScript file (Visual Basic Script)
.JARJava Archive
.EX4MetaTrader 4 Compiled Program (Expert Advisor / Indicator / Script)
.APPXMicrosoft Windows App Package (AppX)

Free file tools

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

Open the toolbox

Browse file extensions A-Z