Name

file

Synopsis

file [options] files

Classify the named files according to the type of data they contain. file checks the magic file (usually /usr/share/magic) to identify some file types. If the file type cannot be determined, it is shown as “data.” file does its best to identify the file type, but it is sometimes incorrect. See also the strings command to search for printable strings in nontext files.

Options

-b, --brief

Brief mode; do not prepend filenames to output lines.

-c, --checking-printout

Check the format of the magic file (the files argument is invalid with -c). Usually used with -m.

-f file, --files-from file

Read the names of files to be checked from file.

-h, --no-dereference

Do not follow symbolic links. The default unless the environment variable POSIXLY_CORRECT is defined.

--help

Print help message and exit.

-i, --mime

Print mime strings rather than the traditional strings.

-L, --dereference

Follow symbolic links. By default, symbolic links are not followed.

-m file, --magic-file file

Search for file types in file instead of /usr/share/magic, where file can be either a single file or a colon-separated list of files.

--mime-type, --mime-encoding

Like -i, but print only the mime type or the mime encoding.

-n, --no-buffer

Flush standard output after checking a file.

-N, --no-pad

Do not pad filenames to align in the output.

-s, --special-files

Check files that are block or character special files in addition to checking ordinary files.

-v, --version

Print the version.

-z, --uncompress

Attempt ...

Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.