How do I determine the filetype of an unknown file?

Use file to determine the type of a file. For example, you receive the file unknown from another user and you want to know sort of file is unknown.

file unknown

unknown:    JPEG image data, JFIF standard

file returns that unknown is a Jpeg file, you can view jpeg files with xv

Note: file is found at /usr/local/bin/file

About filename extensions.
Filename extensions are the end of a filename following a period. For instance the file hello.ps has the extension ps, commonly used for Postscript Documents. Extensions are used to set the type of a file in Operating Systems such as DOS, Windows and OS/2. UNIX, however, does not care about the extension of a file. A file on hello.ps may return uuencoded text or gzip compressed data. It is important to remember that the extension tells us nothing about the actual contents of the file.

Common File Types and associated Applications
Assumes you have typed:file filename

ASCII text Any text editor, examples are:
vi
emacs
dtpad
pico
ASCII C program text, with CRLF line terminators gcc
cc
Bourne shell script text executable This is a script, type ./filename to run it.
ELF 32-bit MSB executable, SPARC, version 1, dynamically linked (uses shared libs), stripped This is an application, type ./filename to launch it.
(This application will only run on a Sun Server: monaco, fresno, zurich...)
GIF image data, version 89a, height x width xv
gimp
gzip compressed data, deflated  
HTML document text firefox
hotjava
compiled Java class data, version 45.3 java
LaTeX 2e document text latex
news or mail text mail
elm
pine
mutt
Microsoft Office Document StarOffice, or a Windows Machine
MS-DOS executable (EXE), OS/2 or MS Windows A machine running Windows
Simonyi Hall 028,
Simonyi Hall 114
PDF document, version 8.1.3 Adobe Acrobat Reader acroread
gv
perl script text This is a script, type ./filename to run it.
PostScript document text conforming at level 2.0 ghostview
evince
gv
GNU tar archive
tar archive
tar
uuencoded or xxencoded text uudecode
Zip archive data, at least v2.0 to extract unzip