LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-07-2003, 09:36 PM   #1
manaa
LQ Newbie
 
Registered: Feb 2003
Posts: 1

Rep: Reputation: 0
Question Linux file extension vs Dos file Extension?


please compare or describe linux file extension with DOS /Window file extensions.
thanks
 
Old 02-08-2003, 12:19 AM   #2
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Re: Linux file extension vs Dos file Extension?

Quote:
Originally posted by manaa
please compare or describe linux file extension with DOS /Window file extensions.
thanks
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 `myperl.pl' 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,

Rick
 
1 members found this post helpful.
Old 02-12-2009, 12:40 PM   #3
studiogrynn
LQ Newbie
 
Registered: Feb 2009
Posts: 8

Rep: Reputation: 7
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?
 
Old 02-12-2009, 12:53 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
the file command uses something called a magic database (http://linux.die.net/man/5/magic) 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.
 
1 members found this post helpful.
Old 02-12-2009, 01:24 PM   #5
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
man file for an explanation of how it works..
 
Old 02-12-2009, 03:29 PM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
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

data.mp3.bak.obsolete

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).
 
1 members found this post helpful.
Old 02-12-2009, 04:19 PM   #7
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
http://letmegooglethatforyou.com/?q=...ile+extensions

there you go.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
why when redirecting output to a file any file extension seems to be fine? dr_zayus69 Linux - General 1 05-21-2005 04:09 AM
Why when editing files does Linux create a duplicate file with a ~ in the extension? bugbite99 Linux - General 6 01-17-2005 02:21 PM
.la file extension n_hendrick Linux - Newbie 1 01-11-2004 04:20 PM
how to install sound and modem driver in tar.gz file extension in linux 7.3 nomi Linux - General 2 09-17-2003 01:24 PM
file extension help Netrack Linux - Newbie 9 01-21-2003 08:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration