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 05-15-2008, 01:24 AM   #1
Mustafa^Qasim
Member
 
Registered: Dec 2005
Location: Lahore, PK
Distribution: Fedora 14
Posts: 105

Rep: Reputation: 16
Red face File Extension in Linux : Still Confused


Hello!
After reading previous posts regarding file extension in Linux I am still wondering why File Extension considered a topic used to differentiate between Windows n Linux. What I think is that giving extensions to files makes the OS a favor in understanding which application to use for opening this file if someone try to open it without mentioning the target software. Probably it's just a general feature that if it is used it help making OS user friendly.

If Windows is blamed to be strict about extensions then HOW (means wat's the logic behind that) Linux makes sense if I put 3 different files with no extension in s folder and try to open them. How my Window manager will make sense that it is a gif, ogg or spreadsheet file?

Is there any trick used like storing file type in file's header so we don' need to put extension in its name?
 
Old 05-15-2008, 01:43 AM   #2
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
Hi,
All files begin with a magic 16 or 32 bits number specific to its type, some examples:
-"BM" (0x424d) for bmp files,
-"#!" (0x2321) for shell scripts,
-"RIFF" (0x52494646) for wav files,
-...

That's how linux (and i think all unix flavors) determine how to handle a file. You have the "file" utility which illustrate that. File extension is just for the user convenience...
 
Old 05-15-2008, 01:54 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
From the users point of view, the extension may be used. For example if you use KDE or Gnome, you use the mime type to determine the default application. The kernel doesn't care what the extension is. The user, group & other "x" bits determines if a file is executable. You may find the "file" command interesting. It looks inside the files to determine what they are. Suppose you accidently renamed a file "puppy.jpg" to "puppy" and later you wonder what the "puppy" file is. You can run "file puppy" and find out that it is a jpeg file.
 
Old 05-15-2008, 04:04 AM   #4
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Though 'file' doesn't know every single file type in existence, as far as I know. Correct me if I'm wrong, but I think it uses a database of some sort about the "known" file types and their "fingerprints", and if there's a file not known to it, it is unable to specify it's type in detail (maybe it then says just "data" or something?).

But yes, the extensions as such don't matter that much. Desktop environments do occasionally make some sort of use of them, though. And on (at least recent) desktop environments, if you rename a file by pressing F2 (or whatever is the short cut for it), the name part of the file gets "painted" and the extension not - so if you press the shortcut and start writing a new name, the filename's name part gets rewritten but extension not. In older versions I recall the same action would simply overwrite the whole name, including extension. User-"friendliness" I suppose..
 
Old 05-15-2008, 06:31 AM   #5
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
If you take a look at the manual page for magic it may help.
 
Old 05-19-2008, 10:56 AM   #6
Mustafa^Qasim
Member
 
Registered: Dec 2005
Location: Lahore, PK
Distribution: Fedora 14
Posts: 105

Original Poster
Rep: Reputation: 16
How to manage files generated by software's with custom extension?

So, if I've installed a software e.g a graphic animation software and the projects files are saved as .abc extension. The only way to let the desktop remember to open it in that graphic tool is extension. Or Linux has any solution for that?

Does the No File Extension feature limited to Command Line Interface (CLI)?
 
Old 05-19-2008, 11:32 AM   #7
vadkutya
Member
 
Registered: Apr 2008
Distribution: slackware 10.2
Posts: 117

Rep: Reputation: 17
Quote:
HOW (means wat's the logic behind that) Linux makes sense if I put 3 different files with no extension in s folder and try to open them
it is not the purpose of linux to make sense of your filenaming. a good program doesn't really depend on filename extensions. for example gqview (image viewer). it doesn't matter what the extension is. if it's an image/picture it will display it.

it's one of the purposes of a desktop environment like kde or gnome however to remember what kind of file it is dealing with by looking at the extensions. you can change this behaviour to your likings. so where is the problem?

Quote:
The only way to let the desktop remember to open it in that graphic tool is extension.
yes as far as i know. but kde/gnome and the like do this as good as windows .

Quote:
Does the No File Extension feature limited to Command Line Interface (CLI)?
what is this supposed to mean?

vadkutya
 
Old 05-19-2008, 11:34 AM   #8
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Desktop environments can and do deal with mime types and can and do set certain file types to be opened with certain applications..so even if you installed a program that used file types that were not recognized by 'file' or such utilies, yes, you could set your desktop environment to open that certain app whenever you click the file open from your favourite file manager.

It seems the desktop relies more on mime types than any "magic headers" - if you rename a .jpg file to .txt and double-click on it, very probably your system either asks what you'd like to do with it or just tries to open it with something that is not an image viewer. Though there is no reason why a graphical application could not check the file's type the same way 'file' program does, it could be that it's nowadays just practical in graphical desktops to stick to mime types.
 
Old 05-19-2008, 07:05 PM   #9
Mustafa^Qasim
Member
 
Registered: Dec 2005
Location: Lahore, PK
Distribution: Fedora 14
Posts: 105

Original Poster
Rep: Reputation: 16
Quote:
Quote:
Does the No File Extension feature limited to Command Line Interface (CLI)?
what is this supposed to mean?
means different desktop tools generate custom files like a graphic animation application saves it's project files with .abc extension. So, in Desktop we had to depend on mime types like Windows but at CLI we don't have the option of such tools that generate files with custom extension. If some does it will be one of the standard file types that the file command will identify but at desktop Linux behaves like M$.
 
Old 05-19-2008, 07:16 PM   #10
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
A text file without a .txt extention will still be identified as a text file and can be opened by double clicking on it.

You could try an experiment and copy-paste different types of files in konqueror; remove the file extension for the copy and see for yourself whether the filetype is identified properly.

For example, removing the .pdf extension from a PDF document; the document will be identified correctly in the konqueror file browser. However in the shell, if you enter "acroread " and press tab, it won't show up in the autocompletion list.

Last edited by jschiwal; 05-19-2008 at 07:27 PM.
 
  


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
Linux file extension vs Dos file Extension? manaa Linux - Newbie 6 02-12-2009 04:19 PM
How write linux make file for php extension Janehe Programming 0 08-23-2006 03:32 PM
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
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

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

All times are GMT -5. The time now is 09:43 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