chrishoffman — 2014-07-07T04:04:17-04:00 — #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 — 2014-07-07T04:57:36-04:00 — #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 — 2014-07-07T05:24:55-04:00 — #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 — 2014-07-08T12:41:19-04:00 — #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 — 2014-07-08T19:47:19-04:00 — #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 — 2014-07-17T04:04:25-04:00 — #6
This topic was automatically closed after 10 days. New replies are no longer allowed.