
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.
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)
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…
15 thoughts on “How to install LibreOffice 24.2 on Linux Mint, Ubuntu, MX Linux, Debian…”
You may use the official appimage in Libre Office as well. In fact, on Linux Mint 21 you can’t get rid of the default LO as it may lead to dependency issues. Appimage helps.
Pingback: Ubuntu 21.04: Essentials – Linux Sagas
Issuing
$ sudo apt-get remove libreoffice-core
installs an office core no gui. With or without purging. Yielding this:The following packages will be REMOVED:
libreoffice-base libreoffice-calc libreoffice-core libreoffice-draw libreoffice-gnome libreoffice-gtk3 libreoffice-impress libreoffice-lightproof-ru-ru libreoffice-math libreoffice-nlpsolver libreoffice-report-builder libreoffice-report-builder-bin libreoffice-script-provider-python libreoffice-sdbc-postgresql libreoffice-wiki-publisher python3-uno
The following NEW packages will be installed:
libreoffice-core-nogui
Many thanks for any clarification!
Right! The correct command for removing completely the stock LibreOffice on Linux is the following:
sudo apt purge libreoffice-common
The following command also works but misses some packages:
sudo apt purge libreoffice*
Thank you for your comment, I updated the article accordingly.
NOTE:- I found that Libre Office version 6.3.2.2 is extremely buggy, it has major dependency problems attempting to install on Linux Mint (Tina 19.2). I wasn’t able to resolve these problems so had to revert the install (remove 6.3.2.2-2) and return to previous version 6.3.1 which works fine.
**Windows 10 (1903) ALSO NOTE that LO 6.3.2.2 installs on W10 but also caused major performance issues and hung my system on reboot. My machine Borked badly so once again had to revert back to LO 6.3.1 which works fine.
Thanks for the Terminal codes. Newbies like me just want it to work and your codes provide the copy and paste necessities for Linux to do its magic.
(If it can’t be done in Linux (and LibreOffice) its not worth doing)
please help me with this error, newbee here
root@Anon:~/libreoffice# sudo dpkg -i *.deb
dpkg: error: dpkg status database is locked by another process
root@Anon:~/libreoffice# cd LibreOffice_6.0.2.1_Linux_x86_deb
root@Anon:~/libreoffice/LibreOffice_6.0.2.1_Linux_x86_deb# sudo dpkg -i *.deb
dpkg: error: dpkg status database is locked by another process
root@Anon:~/libreoffice/LibreOffice_6.0.2.1_Linux_x86_deb# cd debs
bash: cd: debs: No such file or directory
root@Anon:~/libreoffice/LibreOffice_6.0.2.1_Linux_x86_deb# cd DEBS
root@Anon:~/libreoffice/LibreOffice_6.0.2.1_Linux_x86_deb/DEBS# sudo dpkg -i *.deb
dpkg: error: dpkg status database is locked by another process
root@Anon:~/libreoffice/LibreOffice_6.0.2.1_Linux_x86_deb/DEBS# sudo dpkg -i *.deb
dpkg: error: dpkg status database is locked by another process
The last line says it all: check if you are running another instance of dpkg. In last resort, try to remove dpkg lock file:
sudo rm /var/lib/dpkg/lock
Then let dpkg fix itself:
sudo dpkg --configure -a
Note that this problem is not per se related to LibreOffice.
In Ubuntu, you could use this repository and LibreOffice will always be upgraded to the latest version:
sudo add-apt-repository ppa:libreoffice/ppa
Details here:
http://tipsonubuntu.com/2017/01/31/install-libreoffice-5-3-ubuntu/
Please mind that the mentioned PPA is only available on LTS and the latest non-LTS release.
Thank you Stefano, that was the info I was looking for. This method works even for LibreOffice 6.
Would be useful to know how to install such alongside the native repository install of LibreOffice – without conflict. Would be useful to be able to choose, say, LibreOffice Writer 5.2, vs just LibreOffice Writer. Migrations / new versions not always working as seamlessly as one might like with files one might already have. It can be very frustrating to have a new version munge (e.g. formatting) of a current document one depends on, and not being able to ‘un-munge’ it.
Install alacarte to manage the menu itens.
Thanks Ogalho. Alacarte is a great tool, though it has not been updated for a while. An alternative is MenuLibre, which is also not very often updated. Anyway, here is a tutorial for Alacarte:
https://www.howtoforge.com/tutorial/how-to-manage-main-menu-icons-in-gnome/
Alacarte for Linux Mate Edition is named Mozo.
All of them should be good enough to create menu shortcuts for LibreOffice!
Works well. The only problem I had is that the icons were not created. I created them manually by running Writer, Calc and Impress and the using the “Lock to Launcher” option. This is how to run them from the terminal:
Writer: /opt/libreoffice5.0/program/oosplash –writer
Calc: /opt/libreoffice5.0/program/oosplash –calc
Impress: /opt/libreoffice5.0/program/oosplash –impress