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



The MIME Database

The MIME database is a collection of files that make up:

  • The set of known MIME types

  • The method for determing the MIME type of a file

  • Meta information regarding a MIME type, such as a human readable description to use when displaying files of this type.


As an administrator, the most important and basic step to understanding the MIME system is learning the locations where these files are stored. Since the XDG shared mime info specification was drafted by the X Desktop Group, it also makes use of the XDG base directory specification. It is highly recommended that you familiarize yourself with this specification, as it is also important for other system administration tasks such as editing menus. A brief summary of the directory locations as pertaining to the MIME specification is given below.

The MIME database is created from the set of files located in the $XDG_DATA_HOME/mime and $XDG_DATA_DIRS/mime directories. If these environment variables are unset, then they default to the values ~/.local/share and /usr/local/share:/usr/share respectively. As can be seen from the default value for $XDG_DATA_DIRS , each environment variable is actually a colon separated list of directories. The user's database at $XDG_DATA_HOME/mime has precedence over the system database at $XDG_DATA_DIRS/mime when conflicting definitions are encountered. Similar to the XDG shared mime specification, we will refer to this set of directories as <MIME> in the rest of this document.

For example, assuming default paths for the environment variables, “Load <MIME>/text/plain.xml” means to load the following files:

  • ~/.local/share/mime/text/plain.xml

  • /usr/local/share/mime/text/plain.xml

  • /usr/share/mime/text/plain.xml


The following is a list of directories and files that are found inside the MIME database along with brief descriptions:


This directory contains any number of XML files, each of which describe a collection of MIME types. By default, the file is installed in the /usr/share/mime/packages directory. This file contains all the default MIME types that are widely used and recognized.

Applications which provide information about new MIME types are to install a single new XML file here. Depending on the prefix where the application is installed, it will create the file in the /mime/package subdirectory of one of the directories in $XDG_DATA_HOME:$XDG_DATA_DIRS. For example, an application installed to /usr/bin should install a new source XML file to the /usr/share/mime/packages directory. For more information about the XML files in the packages directory, please see the section called “The source XML files”.


These directories and files are automatically generated from the collection of source XML files in the <MIME>/packages/ subdirectory by the update-mime-database application. For example, for each mime-type element in the /usr/share/mime/packages/ file, a directory is created at /usr/share/mime/ with the media type of the MIME type. An XML file is created in that directory with the subtype identifier of that MIME type as well. The contents of the created XML file include comments (and translations for them), subclasses designations and aliases.

Example 5.1. Example: /usr/share/mime/text/plain.xml file

<?xml version='1.0' encoding='utf-8'?>
<mime-type xmlns="" type="text/plain">
<!--Created automatically by update-mime-database. DO NOT EDIT!-->
  <comment>plain text document</comment>
  <!-- possibly more translations -->
  <comment xml:lang="es">documento de texto sencillo</comment>
  <comment xml:lang="eu">testu soileko dokumentua</comment>
  <comment xml:lang="fi">perustekstiasiakirja</comment>
  <comment xml:lang="fr">document plein texte</comment>
  <!-- possibly more translations -->

This file is generated by the update-mime-database application, using the default source XML file


Contains one line with a MIME type and a glob pattern, separated by a colon. Files which match the glob pattern are resolved to the MIME type specified before the colon. There are special rules about how filenames are matched by the glob pattern; for more details see the XDG shared mime specification.

This file is also generated by the update-mime-database application, using the default source XML file


A binary file which contains information on how to resolve MIME types by “sniffing” the content of the file. This is generally a set of one or more rules such as “check for the string %PDF- at byte offset 0 in the file; if found, assign it the MIME type application/pdf”.

This file is also generated by the update-mime-database application.


Contains a mapping of XML namespaces to MIME types. Each line contains three fields, the namespace, the localName and the MIME type. Each field is separated by a space. If the localName is empty, then there are two spaces between the namespace and the MIME type.

This file is also generated by the update-mime-database application.


Contains a list of aliases for each MIME type. An alias is simply a MIME type that is sometimes known as another type. For each line in this file there are two fields: the first field is the alias name, and the second field is the MIME type. The fields are separated by a space.

This file is also generated by the update-mime-database application.


Contains a list of subclassed MIME types and their “parent” MIME type. From the XDG shared mime specification:

A type is a subclass of another type if any instance of the first type is also an instance of the second. For example, all image/svg files are also text/xml, text/plain and application/octet-stream files. Subclassing is about the format, rather than the catagory of the data (for example, there is no 'generic spreadsheet' class that all spreadsheets inherit from).

The format of this file is similar to the aliases file. Each line contains two fields, where the first field is the subclassed MIME type and the second field is the parent MIME type. Each field is separated by a space.

This file is also generated by the update-mime-database application.

Refreshing the MIME Database

Understanding how to refresh the MIME database is important for administrators who wish to add new MIME types to the system, or otherwise modify information about a MIME type. The application update-mime-database is intended for this purpose.

For example, if an application installs information about a new MIME type to /usr/share/mime/packages/diff.xml, then update-mime-database must be called with the parameter /usr/share/mime.

# update-mime-database /usr/share/mime
* Updating MIME database in /usr/share/mime...

The MIME database is refreshed by scanning all the source XML files in the directory <MIME>/packages.

Introduction to MIME Types
GNOME 2.14 Desktop System Administration Guide Next
The source XML files

  Published under the terms of the GNU General Public License Design by Interspire