Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




SUSE Linux Enterprise Desktop Deployment Guide
Previous Page Home Next Page

9.5 MIME Types

A Multipurpose Internet Mail Extension (MIME) type identifies the format of a file. The MIME type enables applications to read the file. Applications such as Internet browsers and e-mail applications use the MIME type to handle files of different types. For example, an e-mail application can use the MIME type to detect what type of file is attached to an e-mail.

The Nautilus file manager uses MIME types to identify the type of a file. The file manager needs to know the MIME type of a file to perform the following tasks:

  • Open the file in an appropriate application

  • Display a string that describes the type of file

  • Display an appropriate icon to represent the file

  • Display a list of other applications that can open the file

It is sometimes necessary to work out the correct MIME type for a file. This is usually done by examining the file's name or contents and looking up the correct MIME type in a database. If you add a new application (that is, extend the database), you must make sure that other applications can recognize the files associated with the application. For example, you might want to add the following:

  • image/png files should be edited using the Gimp.

  • image/png files should be described in English as Portable Network Graphics files.

  • Files whose names end in .png should have the type image/png.

You can use a graphical editor (such as MIME-Editor to edit the database, or you can do it manually by creating a file called $XDG_DATA_HOME/mime/packages/Override.xml in the format described below. For information on the XDG_ variables, see the Base Directory Specification.

When your new application is installed, it should install a file with the application's name in $XDG_DATA_DIRS/mime/packages. For example, running the ./configure && make install command with the Gimp will create /usr/local/share/mime/packages/gimp.xml.

This file has the following format:

<?xml version=”1.0” encoding=”UTF-8”?>
<mime-info xmlns=””>
   <mime-type type=”image/png”>
         <comment xml:lang=”en”>PNG image</comment>
         <comment xml:lang=”af”>png bleed</comment>
         <magic priority=”50”>
                <match type=”string” value=”\x89PNG” offset=”0”/>
         <glob pattern=”*.png”/>

This provides a comment in two languages, a rule to recognize PNG files by their contents, and a rule to recognize PNG files by their names. You can provide information about several types in the single application.xml file. You do not need to provide any information which is also in the base package.

You can also add extra elements if they are namespaced to avoid conflicts. For example:


This indicates that the named desktop entry file describes an application that can edit image/png files.

Information added to the database should be static (for example, “The Gimp can edit PNG files.”), not configuration (for example, “The Gimp is the preferred editor for PNG files.”). For more information on storing configuration information, see the Shared Configuration System Spec.

After you have installed the application.xml file, run the update-mime-database command to rebuild the output files. This program checks that the syntax of your file is correct and merges the information in it with the information in the other XML files in the packages directory. It then puts the rules for recognizing files into one set of files and the information about each type into other files (for example, $XDG_DATA_DIR/mime/image/png.xml) where other programs can easily access it.

When the application is uninstalled, the application.xml file is removed. Run update-mime-database again to remove the information from the database.

SUSE Linux Enterprise Desktop Deployment Guide
Previous Page Home Next Page

  Published under the terms of the Open Publication License Design by Interspire