file
content-based file type identification
TLDR
Determine file type
SYNOPSIS
file [options] files...
DESCRIPTION
file determines file types by examining content rather than extensions. It uses magic number patterns and heuristics from a database to identify formats.
The tool recognizes thousands of file types including executables, archives, documents, images, and text encodings. It examines file headers and content patterns rather than trusting filename extensions.
file is essential for identifying unknown files and verifying file types in scripts.
PARAMETERS
FILES
Files to identify.-b, --brief
Omit filename from output.-i, --mime
Output MIME type and encoding.--mime-type
Output MIME type only.-L, --dereference
Follow symlinks.-z, --uncompress
Look inside compressed files.-f FILE
Read filenames from file.--help
Display help information.
CAVEATS
May misidentify corrupted or unusual files. Custom formats may not be recognized. Magic database completeness varies.
HISTORY
file dates back to Unix Version 6 (1975). The magic file database approach was developed to identify the many file formats accumulating on Unix systems.
