commands

file — classify file kind or content

Classifies a path using metadata and content patterns. Descriptions depend on the implementation and magic database; the result is not a security verdict. Some classification errors do not affect status unless -E is given. Examples assume a fresh chapter files lab.

Formal Syntax & Structure

linux syntaxlinux
file [OPTION]... FILE...

Parameters & Attributes

NameTypeDescription
-boptionOmit filename prefix
-LoptionFollow symbolic links
-EoptionTreat filesystem errors as errors affecting exit status
FILEoperandPath to classify

Return Value

text and exit status

Prints a classification rather than a Boolean verdict. Some filesystem errors are reported in the classification while status remains 0; use -E when error status is needed and inspect diagnostics.

Working Example

Example Snippetlinux
file -b notes/hello.txt
Linux Reference