OS Manuals

/usr/bin/file

file-type identification utility

From file 5.48-r3 (os), captured 2026-11-05 by running file --help (exit 0). permalink

Usage: file [OPTION...] [FILE...]
Determine type of FILEs.

      --help                 display this help and exit
  -v, --version              output version information and exit
  -m, --magic-file LIST      use LIST as a colon-separated list of magic
                               number files
  -z, --uncompress           try to look inside compressed files
  -Z, --uncompress-noreport  only print the contents of compressed files
  -b, --brief                do not prepend filenames to output lines
  -c, --checking-printout    print the parsed form of the magic file, use in
                               conjunction with -m to debug a new magic file
                               before installing it
  -e, --exclude TEST         exclude TEST from the list of test to be
                               performed for file. Valid tests are:
                               apptype, ascii, cdf, compress, csv, elf,
                               encoding, soft, tar, json, simh,
                               text, tokens
      --exclude-quiet TEST   like exclude, but ignore unknown tests
  -f, --files-from FILE      read the filenames to be examined from FILE
  -F, --separator STRING     use string as separator instead of `:'
  -i, --mime                 output MIME type strings (--mime-type and
                               --mime-encoding)
      --apple                output the Apple CREATOR/TYPE
      --extension            output a slash-separated list of extensions
      --mime-type            output the MIME type
      --mime-encoding        output the MIME encoding
  -k, --keep-going           don't stop at the first match
  -l, --list                 list magic strength
  -L, --dereference          follow symlinks (default if POSIXLY_CORRECT is set)
  -h, --no-dereference       don't follow symlinks (default if POSIXLY_CORRECT is not set) (default)
  -n, --no-buffer            do not buffer output
  -N, --no-pad               do not pad output
  -0, --print0               terminate filenames with ASCII NUL
  -p, --preserve-date        preserve access times on files
  -P, --parameter            set file engine parameter limits
                                   bytes 7340032 max bytes to look inside file
                               elf_notes     256 max ELF notes processed
                               elf_phnum    2048 max ELF prog sections processed
                               elf_shnum   32768 max ELF sections processed
                               elf_shsize 134217728 max ELF section size
                                encoding   65536 max bytes to scan for encoding
                                   indir      50 recursion limit for indirection
                                    name     150 use limit for name/use magic
                                   regex    8192 length limit for REGEX searches
                                 magwarn      64 maximum number of magic warnings
  -r, --raw                  don't translate unprintable chars to \ooo
  -s, --special-files        treat special (block/char devices) files as
                             ordinary ones
  -S, --no-sandbox           disable system call sandboxing
  -C, --compile              compile file specified by -m
  -d, --debug                print debugging messages

Report bugs to https://bugs.astron.com/
Options (31)
OptionDescriptionSource
--helpPrint a help message and exit.help + man
-v, --versionPrint the version of the program and exit.help + man
-m, --magic-file LISTSpecify an alternate list of files and directories containing magic.help + man
-z, --uncompressTry to look inside compressed files.help + man
-Z, --uncompress-noreportTry to look inside compressed files, but report information about the contents only not the compression.help + man
-b, --briefDo not prepend filenames to output lines (brief mode).help + man
-c, --checking-printoutprint the parsed form of the magic file, use in conjunction with -m to debug a new magic file before installing ithelp + man
-e, --exclude TESTExclude the test named in testname from the list of tests made to determine the file type.help + man
--exclude-quiet TESTLike --exclude but ignore tests that file does not know about.help + man
-f, --files-from FILERead the names of the files to be examined from namefile (one per line) before the argument list.help + man
-F, --separator STRINGUse the specified string as the separator between the filename and the file result returned.help + man
-i, --mimeCauses the file command to output mime type strings rather than the more traditional human readable ones.help + man
--appleCauses the file command to output the file type and creator code as used by older MacOS versions.help + man
--extensionPrint a slash-separated list of valid extensions for the file type found.help + man
--mime-typeLike -i, but print only the specified element(s).help + man
--mime-encodingoutput the MIME encodinghelp
-k, --keep-goingDon't stop at the first match, keep going.help + man
-l, --listShows a list of patterns and their strength sorted descending by magic(4) strength which is used for the matching (see also the -k option).help + man
-L, --dereferenceThis option causes symlinks to be followed, as the like-named option in ls(1) (on systems that support symbolic links).help + man
-h, --no-dereferenceThis option causes symlinks not to be followed (on systems that support symbolic links).help + man
-n, --no-bufferForce stdout to be flushed after checking each file.help + man
-N, --no-padDon't pad filenames so that they align in the output.help + man
-0, --print0Output a null character ‘0’ after the end of the filename.help + man
-p, --preserve-dateOn systems that support utime(3) or utimes(2), attempt to preserve the access time of files analyzed, to pretend that file never read them.help + man
-P, --parameter name=valueset file engine parameter limits bytes 7340032 max bytes to look inside file elf_notes 256 max ELF notes processed elf_phnum 2048 max ELF prog sections processed elf_shnum 32768 max ELF sections…help + man
-r, --rawDon't translate unprintable characters to ooo.help + man
-s, --special-filesNormally, file only attempts to read and determine the type of argument files which stat(2) reports are ordinary files.help + man
-S, --no-sandboxOn systems where libseccomp (https://github.com/seccomp/libseccomp) is available, the -S option disables sandboxing which is enabled by default.help + man
-C, --compileWrite a magic.mgc output file that contains a pre-parsed version of the magic file or directory.help + man
-d, --debugPrints internal debugging information to stderr.help + man
-EOn filesystem errors (file not found etc), instead of handling the error as regular output as POSIX mandates and keep going, issue an error message and exit. (in the manual page but not in --help)man
Exit status (1) from the manual page
0the operation was successful or >0 if an error was encountered
Examples (4) from the manual page, untested

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.