Forever & AlwaysLINUX COMMAND ATLAS

LINUX COMMAND ATLAS · COMMAND GUIDE

Linux file command

Identify a file’s type by examining its contents and metadata.

file utility

Syntax

Command form
file [OPTION]... FILE...

Common options

6 options
OptionWhat it does
-b, --briefDo not prepend filenames to output.
-i, --mimeOutput MIME type information.
-L, --dereferenceFollow symbolic links.
-k, --keep-goingContinue checking after the first match.
-z, --uncompressTry to inspect compressed files.
-s, --special-filesRead block or character special files.

Usage examples

3 examples

Identify a file’s type by examining its contents and metadata.

file ./download.bin

Identify a file from its contents and metadata.

file archive.tar.gz

Print only the MIME type information.

file --mime-type image.png

Notes

file identifies types heuristically; it does not guarantee that a file is safe or valid.