file

Determine file type by inspecting content (not extension).

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

file tests files and reports their type based on magic bytes in the content, not the filename extension. Crucial for identifying mislabeled files, checking if a binary is ELF/ARM/x86, verifying compressed archives, and examining unknown files safely.

Common flags
FlagMeaning
-i --mimeOutput MIME type
-b --briefDon't prepend filename
-L --dereferenceFollow symlinks
Examples
file /usr/bin/kubectlShow ELF architecture of a binary · explain & risk-check →
file *.tar.gzVerify archive types · explain & risk-check →
file -i document.pdfGet MIME type · explain & risk-check →
file image.pngVerify actual file type regardless of extension · explain & risk-check →
Pro tip

Use `file` before executing or extracting unknown files — it reveals if a '.jpg' is actually a shell script or if a binary was compiled for the wrong architecture.

Related
xxd strings stat
Open the full explainer →More in Files & Archives

Reference text is hand-written and may be incomplete — check man file for your version. Test destructive commands on a non-production system first.