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: MEDIUMA .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 nutshellPrograms that open COMMAND files
Technical details
deep spec| File type | Plain-text POSIX shell script |
| MIME type | text/x-shellscript |
| Encoding | UTF-8 (recommended); ASCII also common |
| Line endings | Unix-style LF required; Windows CRLF line endings break script execution |
| Magic bytes | None (plain text); shebang on line 1 identifies the interpreter |
| Execute permission | chmod +x required; without it Finder double-click does not launch Terminal |
| Default interpreter (no shebang) | /bin/sh on macOS |
| Gatekeeper quarantine | Downloaded .command files trigger first-run warning; right-click > Open to bypass |
| Finder double-click behavior | Launches Terminal.app and runs the script in a new window |
| Functional difference from .sh | Extension only; script content identical - .sh opens in text editor, .command executes in Terminal |
| Associated OS | macOS (Finder integration); script syntax runs on any POSIX system |
| Typical file size | 100 bytes - 100 KB |
| Released | ~2001 (Mac OS X 10.0 - Terminal.app era) |
| Open standard | Yes · royalty-free |
| Specification | support.apple.com |
COMMAND conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about COMMAND files.