I may have the wrong idea here, but I thought that:
MIME types are identifying codes, embedded inside a file.
File .extensions are idenifying codes, suffixed to the file's name.
I thought, from something I heard in the dim dark ages, that Linux was .extension agnostic… ( maybe it was in the early days, and things have changed since then…? )
I've recently come from the Windows world, where, at the Operating-System level, a file .extension is the only way (as far as I know) to associate it with its relevant Application program.
Because I don't know why, I find it a bit disconcerting that a file named "fred" and a file named "fred.txt" both open up in a Text Editor.
Is there a clear-cut hierarchy at work here?
Best Answer
MIME types are just a way to name types. They don't have anything to do with how the type of a file is determined.
There are two ways to determine the type of a file: a) Look at its extension and hope that it is accurate or b) look at its contents and then guess based on that. If a file has no extension b is the only option.
Many (binary) file formats have a specific header that you can look at to determine their type. This makes option b quite reliable for those types.
Plain text file formats can often be determined by their structure (if a file contains a lot of html tags, it's probably a html file).
On unix and linux systems you can use the
file
command line utility to find out the type of a file based on its contents.File manager often use some combination of option a and b (e.g. look at the file extension first, if it's not known (or the file does not have an extension), look at the contents).
A file's type is not stored as metadata on common linux file systems.