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.
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
For example, GIMP has the following .desktop file:
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
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 http://library.gnome.org/admin/system-admin-guide/stable/ does not appear to discuss mimeapps.list, but I found the following description on http://live.gnome.org/SysAdminGuideUpdate:
Create a file
then edit the file
I found out the mime type of Truecrypt by following running this command:
I found this link concerning default association, it might be helpful.
per user association:
syntax is as follow:
[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.