-   Linux - Newbie (
-   -   Linux file extension vs Dos file Extension? (

manaa 02-07-2003 09:36 PM

Linux file extension vs Dos file Extension?
please compare or describe linux file extension with DOS /Window file extensions.

rnturn 02-08-2003 12:19 AM

Re: Linux file extension vs Dos file Extension?

Originally posted by manaa
please compare or describe linux file extension with DOS /Window file extensions.

Well, for one thing, DOS actually interprets the file extension and loads the program in a certain way (depending on the extension) to run it. Windows uses the file extension to tell it which application to run to process the file (Word to handle .DOC files, etc.).

UNIX/Linux doesn't use file extensions to figure out how the program should be run. Now some Unix/Linux applications will use a file extension to figure out what to do with a particular file. The best example is Netscape/Mozilla/etc. These browsers use the file extension to launch the correct helper application when you click on a file. I expect that the Nautilus file manager does something similar to tell it how to display an image or how to play an audio file when you leave the mouse on it.

But for things like scripts or compiled programs the use of an extension is mostly to help us humans know what the file is. The perl script `myperl' and `' are two entirely different files. I could write a perl script and name it `myperl.exe' and perl wouldn't care (though I'd have to run it as `myperl.exe' and not just `myperl'. Bottom line is that file extensions are -- for the most part -- optional. You can use them to help you remember what the file contains or you can leave 'em off and use the `file' command to figure out what's inside.

Hope this was helpful,


studiogrynn 02-12-2009 12:40 PM

So how does Linux know?
So then, is Linux using a resource fork like Mac, a registry like M$ or does is it intelligent enough to look into the file header to find the type?

schneidz 02-12-2009 12:53 PM

the file command uses something called a magic database ( to find out file types.

unlike windows if you rename hello.doc to hello.mp3, windows will think it is an mpeg layer 3 audio file.
whereas in linux if you rename hello.doc to hello.mp3, it will continue to know it is an open-office document.

farslayer 02-12-2009 01:24 PM

man file for an explanation of how it works..

salasi 02-12-2009 03:29 PM

Hey, these homework questions get better!

The unix tradition is that what you call the filename extension doesn't have a particular meaning. the dot is just one of the chars that you can use for a filenname, so, for example


would be a valid, but unusual, filename, where the dos/windows tradition wouldn't like that.

given that the Unix tracition gives no special significance to a three char file type and the dot as a separator, it is unsurprising that the OS doesn't do anything in particular with those three chars. Although, a layer on top of the OS (apps, the GUI if you have one) could use three chars for something special, although you could argue that this is against tradition (for what that's worth).

jstephens84 02-12-2009 04:19 PM

there you go.

All times are GMT -5. The time now is 02:07 AM.