Identify Any File's Real Type with file
Magic-number inspection that sees past wrong extensions — from disk images to scripts to Mach-O binaries.
Run `file <path>` to identify a file by its content signature, or `file -I <path>` for the MIME type.
01Command
Command
$ file ~/Downloads/unknown_file02What it does
file reads each file's leading bytes against the magic database, so a renamed ZIP or an executable disguised as text is exposed instantly. The -b flag omits the filename for cleaner script output, and -I prints the RFC-style MIME type that many web tools expect. It also decodes Mach-O architecture (arm64 vs x86_64), which is how you check whether a binary is universal before running it.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- macOS file — determine file typeEvidence: Documents the file command's magic-number detection and -I MIME mode.
Last verified: 2026-09-17 · Category: Files & Folders