How to change the default application for a type of file in Linux Mint/Ubuntu

File associations on Linux Mint or Ubuntu

This howto explains how to change the default program to open all files with a given extension on Linux Mint and Ubuntu. It also details how to change the default application for a batch of filetypes, for example all audio files or all video files.

Set the default program for a given filetype

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.

Set the default program on Linux Mint or Ubuntu

 

Following instructions are for Linux Mint 11 "Katya". Proceed to the end of the page for instructions for Ubuntu.

Associate all audio and video files to VLC instead of Totem media player (Movie Player)

Video files: .avi .mp4 .mpg .ogv .ogm .mkv .wmv etc.
Audo files: .mp3 .ogg .flac .wav .wma etc.

Open defaults.list with gedit:
gksudo gedit /usr/share/applications/defaults.list

And replace all occurences of totem with banshee/rythmbox/vlc or the media player of your choice.
(Search → Replace → Replace All)

Change MIME types in Ubuntu

Save the modified file, and you're done! Change are effective immediately.

Associate all office documents to LibreOffice instead of OpenOffice.org or Abiword

Office files:  .odt  .ods.  .doc  .docx  .xls  .xlsx  etc.

Open defaults.list with gedit:
gksudo gedit /usr/share/applications/defaults.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!

Ubuntu's case

For an obscure reason, changing the file associations directly in the defaults.list doesn't seem to work Ubuntu 10.10 "Maverick Meerkat". Nevertheless, importing information to the the mimeapps.list works.

The file associations for each user are stored in:
~/.local/share/applications/mimeapps.list

In Ubuntu 10.10 "Maverick Meerkat" (and probably 10.04 "Lucid Lynx"), this file is almost empty. Let's import informations from
/usr/share/applications/defaults.list

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...) Proceed similarly for audio files if needed.

 

By Johannes Eva, January – July 2011
Updated on July 1st, 2011: Ubuntu Linux → Linux Mint 11

Read also:
How to install Firefox on any Linux distribution (Ubuntu, Linux Mint, ...)
How to install LibreOffice 3.5 on Linux Mint, Ubuntu, Xubuntu, Debian...

This article has been linked on Ubuntu News, Debian News, LXer.com, Linux Today, fsdaily.com and some more...