Determine file type by inspecting content (not extension).
low risk
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.
| Flag | Meaning |
|---|---|
-i --mime | Output MIME type |
-b --brief | Don't prepend filename |
-L --dereference | Follow symlinks |
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 →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.
Reference text is hand-written and may be incomplete — check man file for your version. Test destructive commands on a non-production system first.