Set default programs in Ubuntu, Linux Mint, Debian (blue)

How to change the default application for a type of file on Linux

Last updated on October 10, 2022

This howto explains how to change the default program to open all files with a given extension on Linux Mint, Ubuntu, Debian, and most Linux distributions. 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 Nemo / Nautilus / Caja, right-click on any file with the desired file type 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 for a given file type / extension (Here a pdf document in Nemo on Linux Mint)

On Linux Mint, replace step one and two choosing “Open With” → “Other Application…” in the contextual menu, as seen in the picture above.

Change the default app for multiple filetypes

Changing the default application for one type of file is really easy, while changing a batch of file type associations reveals a little clumsier, but extremely efficient.

These instructions should work with a large spectrum of Linux flavours, please share your experience with your favorite distribution in the comments.

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 occurrences of totem with banshee/rythmbox/vlc or the media player of your choice. (Search → Replace → Replace All)

Changing MIME Types (File types) in Linux Mint / Ubuntu screenshot

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!

Other file associations

Use the same technique to change the default application for all kind of file types or extensions, for example:

  • all pictures (.jpg, .png, .gif, etc.) should open up with gThumb instead of EOG/Eye of Gnome/Image Viewer
  • all html documents should open with Firefox instead of Chrome
  • all pdf files should open with Adobe Reader instead of Evince/Document Viewer.

Different solution for some Ubuntu versions

For an obscure reason, changing the file associations directly in the defaults.list doesn’t seem to work on some Ubuntu versions. 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 this file is almost empty. Let’s import informations from /usr/share/applications/defaults.list

Display all the video MIME types / Media 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 occurrences of totem with vlc (Search → Replace…) Proceed similarly for audio files if needed. Unlike the standard method described at the beginning of this article, this method permits to assign a separate program to audio or to video files.

By Johannes Eva, January 2011 – October 2022

This article has been linked on LXer.com, Linux Today and some more…

Articles by categories

Most Read Articles

Comments

3 thoughts on “How to change the default application for a type of file on Linux”

  1. I have .wma audio files showing as text files. It doesn’t help to use “open with” a media player because Mint thinks they’re text docs so nothing happens. Weirdly, one song in one folder IS still an audio file – and plays fine. Is there a global way to wipe out file associations and then re-associate via terminal?

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.