file (determine file type)

This helpful tool can determine the type of almost any file. It does so by identifying “magic numbers” in the file header. For instance, PDF files begin with the magic number 0x25504446, which is the string “%PDF” in ASCII. Here is an example of how to invoke file:

file letter.pdf

When you try this out with some of your own documents (e.g. PDFs, images, DOC files, plain text), you'll notice that file will provide a lot of useful information in addition to telling you the file's type. For example, the utility will determine the architecture of an executable file (e.g. 32 bit or 64 bit), the encoding of a plain text file, and so on.