man.lsPlain-English help for Unix commands

file Identify what type a file is

Looks at the contents of a file, not its name, and tells you what kind of data it holds. Use it when a file has no extension, the wrong extension, or you want to know whether it is text, an image, an archive or a program.

Synopsis

file [OPTION]... FILE...
file -f NAMEFILE

Common options

Option or formWhat it does
-b, --briefBrief: print the type only, without the file name in front
--mime-typePrint only the MIME type, such as text/plain or image/jpeg
-I, --mimeOn macOS, print the MIME type and character set. On GNU/Linux the same job is done by -i (see notes)
-L, --dereferenceFollow symbolic links and report on what they point to
-h, --no-dereferenceDo not follow symbolic links, so a link is reported as a link
-f, --files-fromRead the list of files to check from a file, one name per line
-k, --keep-goingKeep looking after the first match and show every match
-z, --uncompressLook inside compressed files and describe the content

Examples

Check one file
file notes.txt
notes.txt: ASCII text
Check several files at once
file notes.txt data.csv script.sh photos/a.jpg
Check everything in a folder
file docs/*
Print only the type, no file name
file -b notes.txt
ASCII text
Get the MIME type for a script or upload check
file --mime-type notes.txt
notes.txt: text/plain
Find out what a downloaded file really is
file ~/Downloads/mystery-download

Notes

See also

Last reviewed 2026-10-07.