O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

file — stdin  stdout  - file  -- opt  --help  --version

Synopsis

file [options] files

The file command reports the type of a file:

$ file /etc/hosts /usr/bin/who letter.doc
/etc/hosts:    ASCII text
/usr/bin/who:  ELF 32-bit LSB executable, Intel 80386 ...
letter.doc:    Microsoft Office Document

Unlike some other operating systems, Linux does not keep track of file types, so the output is an educated guess based on the file content and other factors.

Useful options

-b

Omit filenames (left column of output).

-i

Print MIME types for the file, such as “text/plain” or “audio/mpeg”, instead of the usual output.

-f name_file

Read filenames, one per line, from the given name_file, and report their types. Afterward, process filenames on the command line as usual.

-L

Follow symbolic links, reporting the type of the destination file instead of the link.

-z

If a file is compressed (see File Compression and Packaging), examine the uncompressed contents to decide the file type, instead of reporting “compressed data.”

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required