|
How to change the default application for a given type of file in Ubuntu Linux
This howto explains how to change the default program to open files of a given extension/MIME type on Ubuntu Linux. It also details how to change the default application for a batch of filetypes, for example all audio files or all video files.
July 2011: Update available on here, also valid for Linux Mint.
Changing the default application for one type of file is very easy, but Ubuntu still lacks an easy way to change a batch of filetype associations.
This howto reveals a clumsy but efficient workaround.
These instructions are for Ubuntu 10.10 "Maverick Meerkat". They should also work with Ubuntu 10.04 "Lucid Lynx" and previous releases, and may be useful for other Linux distributions, but I had no time to do the appropriate testing.
Set the default program to open a type of file
1. In Nautilus, right-click on any file with the desired filetype or extension, choose "Properties" from the context menu.
2. The "Properties" dialog appears. Click on the "Open With" tab.
3. Select the desired application for the given filetype. All files with the same extension will now be opened with this program by default.
Change the default app for multiple filetypes?
The file associations for each user are stored in:
~/.local/share/applications/mimeapps.list
However, in Ubuntu 10.10 "Maverick Meerkat" (and probably 10.04 "Lucid Lynx"), this file is almost empty. The system-wide file associations are stored in:
/usr/share/applications/defaults.list
For an obscure reason, changing the file associations directly in the latter doesn't work on my Maverick system. Nevertheless, importing information from the latter to the former works. To change associations for a batch (and a bunch) of filtypes, follow any of the three examples: video, audio & office documents.
Example 1: .avi .mp4 .mpg .ogv .ogm .mkv .wmv
Associate all video files to VLC instead of Totem media player
Display all the video MIME types associations with this command:
cat /usr/share/applications/defaults.list | grep video
Append all the lines containing video types to the local file:
cat /usr/share/applications/defaults.list | grep video >> ~/.local/share/applications/mimeapps.list
Open defaults.list with gedit:
gedit ~/.local/share/applications/mimeapps.list
And replace all occurences of totem with vlc (Search → Replace...)

Save the modified file, and you're done! Change are effective immediately.
Example 2: .mp3 .ogg .flac .wav .wma etc.
Associate all audio files to Banshee/Rythmbox/VLC
Display all the audio MIME types associations with this command:
cat /usr/share/applications/defaults.list | grep audio
Same procedure: append all the lines with audio filetypes to the local file:
cat /usr/share/applications/defaults.list | grep audio >> ~/.local/share/applications/mimeapps.list
Open defaults.list with gedit:
gedit ~/.local/share/applications/mimeapps.list
And replace all occurences of totem with banshee/rythmbox/vlc ...
(Search → Replace → Replace All)
Example 3: .odt .ods. .doc .docx .xls .xlsx etc.
Associate all office documents to LibreOffice instead of OpenOffice.org
Display all the MIME types associated to OpenOffice.org documents with the following command:
cat /usr/share/applications/defaults.list | grep openoffice.org
Append all the concerned lines to the local file:
cat /usr/share/applications/defaults.list | grep openoffice.org >> ~/.local/share/applications/mimeapps.list
Open the defaults.list description file with gedit:
gedit ~/.local/share/applications/mimeapps.list
And replace all occurences of "openoffice.org" with "libreoffice"
(Search → Replace → Replace All)
Finally, save the file. No need to restart, you're all set!
By Johannes Eva, January 2011
This article has been linked on Tuxmachines, Ubuntu News, LXer.com and some more...
