Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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...
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.
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..
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)?
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)?
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.
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$.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.