Google Answers Logo
View Question
Q: UNIX File Extension ( Answered 4 out of 5 stars,   2 Comments )
Subject: UNIX File Extension
Category: Computers > Operating Systems
Asked by: teddy78-ga
List Price: $10.00
Posted: 17 Apr 2003 09:19 PDT
Expires: 17 May 2003 09:19 PDT
Question ID: 191785
Certain file extensions have a special meaning in for example the MS
Windows operating system, e.g. .com, .exe and .bat means that the file
is executable in the specific way the extension specify. UNIX does not
use such a scheme at all.
I would like to know the advantages and disadvantages of each of these
Subject: Re: UNIX File Extension
Answered By: haversian-ga on 17 Apr 2003 10:51 PDT
Rated:4 out of 5 stars
The use of extensions allows an easy mapping between filetypes and
applications.  Any time you see a file ending in .txt you know it will
open up in (for example) notepad, and is probably a text file.  You
could create a simple webpage in notepad and save it, but that would
result in a .txt file which is not what you want.  Simply renaming the
file .html instead will cause it to open up in a web browser and be
properly parsed as HTML.  This ability to change file types by
changing their name can be very convenient and beneficial.

The use of extensions also has the potential drawback that files can
be named improperly, and can be somewhat cumbersome to use.  What, for
example, is a .aca file or a .669 file?  Without knowing the file
types, you must either trust the OS to "do the right thing" or look
them up every time.  This problem is somewhat patched under Windows by
using icons based on the extension.  When you change a .txt file to a
.html file, the icon will change and should represent in some way the
application that will be opened.  By default, Windows hides the file
types from the user, making it less likely that the user will
accidently clobber a useful extension, but limiting the usefulness of
extensions in the bargain.

UNIX files don't have an extension.  However, you can name a file "my
resume.txt" and many UNIX environments appreciate such
pseudo-extensions.  I say pseudo-extensions because unlike the FAT
filesystem which has separate fields for the name and extension, EXT2
(a common UNIX filesystem) just has one long string which may contain
a dot.  Pseudo-extensions like .txt or .html are purely informative
and optional.  Many unix utilities read and respond to these
extensions, making reasonable guesses as to file contents based on the
extension.  In fact, many UNIX utilities expect and/or require
filenames of a centain type.  I recently ran across a version of gzip
(similar to PKZIP / WINZIP on the Windows platform) which refused to
unzip a file which had been improperly named .tar.gz.tar as it
believed it to be a tar file.  In order to use it, I had to first
rename it .tar.gz so gzip would unzip it and properly create the tar
file.  This example exposes another benefit of not having an explicit
extension - you can use several.  Tar is a common utility for
packaging several files all together in one.  .tar files are commonly
compressed with gzip, and the extension .tar.gz makes this
double-encoding transparent to the user.  If one were to take several
RedHat Packages, tar them up, and zip the result, you could have a
file ending in .RPM.tar.gz to describe for the user what exactly he or
she has.

I hope this has been informative.  As usual, please do request
clarifications if you would like more detail, examples, or if I have
failed to address the intent of your question.

teddy78-ga rated this answer:4 out of 5 stars
Answer is informative, but would be better if you could discuss some
more advantages and disadvantages

Subject: Re: UNIX File Extension
From: y3wn1ck5-ga on 17 Apr 2003 09:55 PDT
In any UNIX enviroment, most files are text based, negating the use of
a file extension.  Example:

/etc/passwd - just a text file containing user information
/etc/inetd.conf - a configuration file for the inetd daemon, .conf is
normally used to specify a configuration file.

The other type of file you will run into is a binary file, which is
the equivalent to an executable in a Windows environment.  You can
find out the types of files with the `file` command:

prompt# file /etc/passwd /usr/sbin/inetd
/etc/passwd:     ASCII text
/usr/sbin/inetd: ELF 32-bit LSB executable, Intel 80386, version 1
(FreeBSD), for FreeBSD 5.0, dynamically linked (uses shared libs),

However, a lot of file extensions do carry over from the Windows
world.  You will run across this especially when you are surfing the
web.  An .mpg file is still an MPEG movie, a .jpg is still a JPEG
picture.  One disadvantage to this is you have to know what program to
use to handle these extensions.  For example, I know to use mplayer to
play movies, and I must setup appropriate mime types in a web browser
to handle this.

Let me compare a batch (.bat) script and a shell script:

For a windows batch script, you must end the file with a .bat
extension for it to run.  In a Unix environment, you can call the
script anything you want, for example /usr/bin/hello_world

echo "Hello World"

Having a general knowledge about MIME types is extremely useful when
it comes to a UNIX environment, but it isn't as heavily dependent on
MIME types as the Windows operating system is.  Hopefully this post
will give you a little insight into how the two environments differ. 
Let me know if you have any other questions.
Subject: Re: UNIX File Extension
From: coriolis-ga on 02 May 2003 18:08 PDT
One of the other things missed in this is the use of policy.

Windows and it's file name extensions are direct result of the severe
restrictions placed on it by MS-DOS.  An operating system desgined to
be vaguely unix like on a  PC. Hence each file has 8 characters for a
name, and 3 for an extension.  This means the system has basically st
a policy saying all files will have a 3 character extension.  DOS
extensions are used to determine (in part) what can done with a file. 
For instance a .COM file tells the system the file is a executable, it
is executable and what memory layout the application uses.  Similarly
.EXE is also execuatable, but uses a different memory layout.

File names where restricted to such a short name as the original disk
systems of DOS were 160kB floppy disks.  DOS was also designed to be
small so hardcoding file sizes makes it easier.

Unix on the other hand was not designed for such small systems.  The
UNIX file system was also much more flexible in many ways.  For
instance any file can have an arbitrary number of names - called hard
links.  So I can create a file, then access it from two points in the
file system.  This also means there is no way to readily associate a
file with it's name (name->file is okay, file(data)->name is not).  So
trying to encode file names with the properties of the file is
pointless.  For example I could have a file with three hardlinks - one
called 'foo.jpg', one called 'foo.exe' and one called 'foo.txt'.  The
only way to work out what the file contains is to look in a file.

In UNIX to work out if a file is executable is stored in it's
permission bits - the exact format is beyond this discussion.  If a
file is executable the system will be happy to let you execute it.  It
then uses the magic numbers in the begining of the file to work out
what to do with it.  If it is a binary file (compiled program) it
loads it and excutes it, else if it is an interpreted program (like a
shell (dos equiv: .bat) or a perl program) it runs the interpreter and
points the interpreter to the file.  The path to the interpreter is
found in the files line of script after a '#!'. (eg #!/usr/bin/perl).

Generally the UNIX method is much more flexible and also avoids a some
problems,  whereas the windows/dos metho is much more limited
enforcing a particular namoing onvention on the user.  For instance
consider JPEG files.  The best extension for these would be .jpeg. 
However since windows is the dominate OS currently .jpg has become the
standard extension.  Similarly mpeg and many other extensions have
been rammed into a 3 letter space.  On a unix system multiple
extensions are possible and frquently used for compressed files and
the like (see other comment on .tar.gz).  Note that unix quite happily
deals with windows 3 character extensions, but windows doesn't deal
with anyone using a 4 character, 6 character or multipl extensions,
hence hte UNIX system is much more flexible.

Finally the use of file extensions to tell the OS about the file has
some serious drawbacks.  A few years back I was doing some work on a
Windows system involving perl scrips (.pl) on a machine which had an
MP3 player which created play list files (.pl).  Basically either I
could get my perl scripst to run or my mp3 player to work, but not
both.  On most unices ths woudl not be a problem.

Hope this gives you some insight ;-)

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy