Computer files are like that. A file is a box of bytes that mean
something to someone. Files have different formats (arrangements of
bytes), and can be handled only by the right application programs. The
problem is that the only quick way to indicate the format is by the
file's name. A file name usually serves two purposes:
2) indicate what to do with them (how to open the box).
Imagine
that you're a fan of fungus in its many fascinating varieties. If your
computer has a file named fungus.gif, there's a good chance it's an
image of a fungus. The .gif is a file extension or suffix. It's a way
of remembering that this file's contents are in an image format called
GIF. There are other image formats, like JPEG (extension .jpg or
.jpeg), PNG (extension .png) and many others. You can view, change, and
create image files with applications such as PhotoShop, the gimp, or
IrfanView.
Depending on the operating system on your computer, the
contents.extension naming method is either a handy naming convention or
a necessity. Microsoft Windows treats the extension with great
reverence. When you double-click on a file's icon, Windows will open
that file with an associated application – and that association is
usually based on the file extension. So you'll see that .doc files are
often opened by Word, .ppt by PowerPoint, and so on. You can change
these associations, or a program can do it for you. If you install
OpenOffice.org (an open-source alternative to Microsoft Office), it can
associate its equivalent programs with the right file extensions.
If you try to change a file's extension, Windows will ask if you
really, really mean it – because you're also changing the program
that's associated with that file. If you renamed fungus.gif to
fungus.mp3, you didn't suddenly change it into a song (.mp3 is the
extension for a music file format). But when you try to use it, the
application associated with .mp3 will look in vain for chords among the
green pixels.
Windows treats some extensions specially -- .exe and .com are
executable programs,and .bat is used by executable scripts. As always,
be careful running a program, especially one you got from the Net. You
don't know where it's been.
Some systems, like Linux, don't care about file extensions. You
could name your image file just fungus, or even fungus.mp3! Some Linux
applications look for different magic byte patterns to verify a file's
format (GIF files start with the three ASCII letters GIF, but get
binary soon after that). Linux indicates that a file is executable – as
well as who is allowed to read and write it – by file permissions
rather than names.
That's if you're using basic, non-graphic Linux. Linux desktops such as
GNOME or KDE often use file extensions, largely because so many people
are used to Windows.
When you browse the web and click on a link, the web server sends
the file's MIME type (a standard way to name file formats) and contents
to your web browser. How does the web server decide the format? Usually
by the file extension. Your browser then decides whether it can either
handle the content itself (it should know how to display GIF, PNG,
JPEG, HTML,and other things), or hand it off to some external
application.