FileSystem


MIME describes the type of data contained in a file. Mime is widely used to indicate which program should open a data file.

Definition of MIME: See http://www.wikipedia.org/wiki/MIME

A variety of methods are used to determine the MIME type of a file. Internet protocols such as http and e-mail usually give the mime type of data explicitly. When opening a file by clicking it in a file manager the filename suffix (such as .pdf) and so called "magic numbers" (such as the fixed bytes in an elf header) are commonly used.

Filename suffices: The system-wide mapping from file suffices to mime types is set in /etc/mime.types .

Users may set their own suffix to mime preferences in $HOME/.mime.types .

Traditionally file name suffices are ignored in unix systems.

Magic Numbers: Magic numbers are bytes or strings that are set to particular values within files of a given type and which can be used to guess the file type with a reasonable amount of certainty. For instance awk scripts usually start with the line "#!/usr/bin/awk" or "#!/bin/awk", possibly with spaces after the !.

A most useful tool for divining the type of a file based on its contents is the terminal command "file". File "file --mime filename" tries to give the mime type of filename.

The "file" command uses magic numbers stored in "/usr/share/file/magic". That file is automatically built and so should not be customised as your precious customisations will get lost when the file is rebuilt. The format of the file is described in man magic.

System-wide additions to the magic-number recognition library live in /etc/magic.

Application specific: Applications may have their own mime-rules. How they implement and record those rules is up to each application. The "application" may be the gnome desktop or a web browser running within gnome, so several rule sets may be checked before /etc/mime.types is referenced.

Default: If the mime type cannot be determined it defaults to application/octet-stream .

Nautilus

You can select the program to handle a file, typing in Nautilus

  applications:///Preferences/Advanced

and selecting file types and programs.

Other way is use the FileTypesProperties . Type in a terminal

 gnome-file-types-properties

You can add system MIME preferences, instead of install webbrowser standalone plugins (see Mozilla, [MozPluggerMIME]).

Mozilla and Nautilus

The Gnome Nautilus Mime Type configuration tool will also define mime types for Mozilla. The configuration tool /usr/bin/gnome-file-types-properties will edit the following user configuration files:

System values:

See also:

MIME (last edited 2007-02-26 03:34:06 by M Des)