chrishoffman at July 7th, 2014 04:04 — #1
Originally published at: http://www.howtogeek.com/192628/mime-types-explained-why-linux-and-mac-os-x-dont-need-file-extensions/
Coming from Windows, file extensions on Linux and Mac OS X can seem a bit strange. The operating system seems to know what files are without relying on the file extension — it does this using MIME types.
adrian_martin at July 7th, 2014 04:57 — #2
The process of how Linux identifies the a files mimetype is a bit vague...from what I know, Linux doesn't actually attempt to identify the files type...The desktop environment does. By various means, not just scanning the 'first' line of a file.
marty_monroe at July 7th, 2014 05:24 — #3
The file command knows nothing about mime types. It identifies a file using tests in the following order: filesystem tests, magic number tests, and language tests. The first test that succeeds causes the file type to be printed. The filesystem test identifies sockets, named pipes, etc. The magic number test, uses the magic file to check for data in a fixed format, such as fixes formats, such as compiled code. If the file does not match the magic number test, it is checked if it is a text file, using different character sets, eg UTF-8. etc. It has been that way since I worked on Unix systems back in the late 1980s, long before mime types, which originate in RFC 2046 from 1996.
troik at July 8th, 2014 12:41 — #4
I would add two things to the discussion:
While mime-types are easy to read for computers, for the user a file-extention can be helpful to understand what type of file you're dealing with.
I would also wager that searching for a specific text file say.... "howtocookchicken.txt on a drive with 50.000 other files is quicker since the OS can red the name and extension from the FAT and doesn't have to open each and every file and read it.
andybalholm at July 8th, 2014 19:47 — #5
The situation in OS X is more complicated than the article makes it sound. It has several ways to determine a file's type:
- The extension. This is the currently-preferred method.
- Classic-Mac-style 4-letter type and creator codes, stored in the file's metadata.
- Examining the file's content, as described in the article.
None of these is explicitly based on MIME types, though they may use MIME types internally. The only OS I know of that actually stores a MIME type for each file is BeOS.
system at July 17th, 2014 04:04 — #6
This topic was automatically closed after 10 days. New replies are no longer allowed.