Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How does Ubuntu or any other Linux systems store file associations?

Is there some /etc/asscociations file or something?

I know that I can right click on file and change it via "open with", but I'm just curious to know how it's stored internally.

share|improve this question
up vote 42 down vote accepted

The file manager (Nautilus, by default) uses the MIME type of a file to determine which program to open it with. When an application is installed, it can specify what MIME types it can open and the command to use to open the files in the .desktop file which is placed in /usr/share/applications. This is the file used for menus, desktop shortcuts, etc.

For example, GIMP has the following .desktop file:

[Desktop Entry]
Name=GNU Image Manipulation Program
GenericName=Image Editor
Comment=Create images and edit photographs
Exec=gimp-2.7 %U

See the MimeType field - this lists the supported MIME types.The Exec field tells the system to use the command gimp-2.7 %U, replacing '%U' with the files to open. (Note GIMP 2.7 is a version I have installed from a PPA, so is higher than the current version in the Ubuntu repositories).

When the application package is installed, the system extracts this MIME type data into a more easily accessible database because looking in each .desktop file would take too long if it was done every time a file was opened.

This tells the system what applications can be used for that MIME type and provides the applications in the 'Open With' list. The default is defined elsewhere. The file /usr/share/applications/defaults.list provides the information for the system defaults. Unless you choose otherwise, these are the applications used when you 'Open' a file.

share|improve this answer
woow. very informative. thanks dv3500ea – Stann Dec 7 '10 at 21:10
After changing MIME types in /usr/share/applications .desktop files, is there a command to re-create that MIME database to see new associations in action? – Redsandro Oct 10 '12 at 16:40
Yes. sudo update-desktop-database See… – NoBugs Dec 22 '12 at 4:13
A more appropriate place for local changes is /usr/local/share/applications. I think gtk looks there, too, by default. It does on my system, but it's been upgraded (not reinstalled) since Ubuntu 7.04 or so. – Peter Cordes Feb 3 '15 at 22:37
Ubuntu seems to follow… , an awesome project. – Ciro Santilli 六四事件 法轮功 包卓轩 Mar 30 '15 at 19:44

To supplement dv3500ea's excellent answer, I would like to add some information about what happens when you change your associations.

While the defaults.list (which you can find by typing 'locate defaults.list') provides the list of applications that are associated with each MIME type, any customizations that you make are stored in your home directory, in ~/.local/share/applications/mimeapps.list. So if you add or remove associations, or change the default association, this file is updated.

The GNOME Desktop System Administration Guide at does not appear to discuss mimeapps.list, but I found the following description on

mimeapps.list is located in $XDG_DATA_DIRS/applications. Its purpose is to add or remove mime associations from applications. nautilus writes ~/.local/share/applications/mimeapps.list when the user makes changes in the "Open With" dialog.

share|improve this answer
But using Ubuntu 12.04, I realize that the mimeapps.list is overridden by entries in the defaults.list. – feeela Jun 25 '12 at 12:55
on 14.04, I was able to s/vlc/mplayer/ in my ~/.local/share/applications/mimeapps.list, and running processes like pcmanfm picked up the changes without restarting. (mplayer.desktop is just runs mplayer. I had one lying around from an old mplayer install in /usr/local, I guess. IDK if having a MimeType=list; was needed or not. – Peter Cordes Feb 3 '15 at 22:35

Create a file truecrypt.desktop in ~/.local/share/applications with the following lines:

[Desktop Entry]
Exec=/usr/bin/truecrypt %U
Comment=manage truecrypt volumes

then edit the file ~/.local/share/applications/mimeapps.list and add the following line:


I found out the mime type of Truecrypt by following running this command:

file --mime-type -b <any truecrypt filename>
share|improve this answer
Nice answer, because it works for those of use who use kde, but have a couple of gtk-native programs, like firefox. – naught101 Apr 24 '12 at 5:57

I found this link concerning default association, it might be helpful.
for global association:


per user association:


syntax is as follow:

[Added Associations]
[Removed Associations]

[Added Associations] section is used to specify preferred (default) applications in decreasing preference. which means desktopfile1 is the most preferred and desktopfileN is least preferred.
[Removed Associations] section is used to explicitly remove any previously inherited associations.

share|improve this answer
This comes from an archlinux site, doesn't necessarily apply on Ubuntu, /usr/share/applications/mimeapps.list doesn't exist. – guntbert Aug 23 '13 at 16:44
Thank you for pointing this out, however the user said in Ubuntu or other Linux systems, this mean this is an answer to his question too :P. – MusuNaji Aug 23 '13 at 17:00
This answer is perfectly ok if you replace mimeapps.desktop with defaults.desktop – szx Apr 26 '14 at 9:26

I found that on my system (Debian Jessie) there's also a ~/.config/mimeapps.list that had an association I accidentally created to open a specific file type with gedit. None of the standard ways of correcting this (default application settings, Thunar's open with property) reflected this, but gedit was the default application.

I was able to remove the line from ~/.config/mimeapps.list and now the correct application opens the file.

share|improve this answer
Thanks, you accidentally helped me to fix Firefox opening everything in Gedit. On openSUSE 13.2 I removed the line with "application/octet-stream=org.gnome.gedit.desktop;". :) – user31389 Mar 4 '15 at 21:01

I was able to set an association like this:

xdg-mime default xnview.desktop image/jpeg

You can also remove associations and do other things: man xdg-mime

I did not need to run sudo update-desktop-database.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.