Setting Default Apps in elementary OS for Every File Type
Elementary OS treats file associations as a small but essential piece of the desktop. When you double-click a PDF in Pantheon Files, the file manager consults a shared database of MIME types, matches the format to a registered handler, and quietly launches the chosen application. That invisible chain of events is what makes a Linux desktop feel coherent, and learning to adjust it lets you shape the experience around the software you actually want to use.
This walkthrough covers the practical ways to change those associations, from the friendly right-click menu to the underlying configuration files. You will see how the open standards behind elementary OS give you control at several layers, so the defaults you pick survive reboots, Flatpak updates, and fresh installs on new hardware.
Understanding MIME Types and How Pantheon Files Picks Handlers
MIME, short for Multipurpose Internet Mail Extensions, started life in the early 1990s as a way to label email attachments. On Linux it has long since become the lingua franca for identifying file contents, and elementary OS relies on it heavily. Every file you open is sniffed, queried against the shared MIME database, and matched with a content type such as application/pdf, image/jpeg, or text/plain. The matched type then resolves to a desktop entry, which in turn points to the executable that actually launches.
Because the same database serves GNOME, KDE, XFCE, and Pantheon, defaults set on elementary OS behave predictably elsewhere. A tinkerer in Adelaide who switches to a Fedora workstation for a weekend project will find that the same MIME definitions govern behaviour there too. The shared-mime-info package is maintained upstream, and elementary's developers do not fork it. They simply trust it, which is why a clean install on a Telstra-supplied NBN line in suburban Brisbane can boot up with sensible defaults already wired in.
The catch is that several layers can declare a handler for the same type. A Flatpak from Flathub, a system Debian package, and a hand-edited entry in ~/.local/share/applications/ may all claim ownership of image/png. When that happens, the most recently registered handler usually wins, which is why a fresh install of Darktable can suddenly take over every photo you open.
The GUI Route: Changing Defaults from the File Manager
The easiest way to change an association is the right-click menu in Pantheon Files. Right-click any file, choose "Open With", and the sub-menu lists every application that has declared it can handle the format. The current default carries a small tick, and selecting any other entry from the list promotes it immediately. The change is written to the user's local database, so it only affects your login and does not require administrator privileges.
This approach works well for the formats most people deal with every day. PDFs, music files, videos, and office documents are all simple to redirect. A user in Perth who prefers OnlyOffice over the default document viewer can right-click a .docx file, point the association at OnlyOffice, and that choice persists for every document opened afterwards.
For batch changes the GUI is less convenient. If you have just installed a new photo editor and want it to handle every common image format at once, you would need to repeat the right-click dance for .jpg, .jpeg, .png, .webp, and the rest. The "Open With" sub-menu also has an "Other Application" option that opens a chooser dialog with a search field, useful when the desired app has not yet registered the type at all.
Command Line Essentials: xdg-mime and gio mime
The two utilities worth memorising are xdg-mime and gio mime. Both come from the freedesktop.org specifications that elementary OS implements, and both let you query and set defaults without leaving the terminal. The xdg-utils package is usually installed by default, while gio is part of GLib and ships with the desktop.
To see which application currently owns a type, open a terminal and run xdg-mime query default image/png. The command prints the desktop file ID of the handler, such as gimp.desktop or org.gimp.GIMP.desktop. To change it, use xdg-mime default org.gimp.GIMP.desktop image/png. The change is written to ~/.config/mimeapps.list, which overrides anything in the system-wide files. Re-running the query confirms the new owner immediately.
gio offers a parallel set of commands. gio mime image/png shows the same information, and both tools read and write the same mimeapps.list file, so you can mix them freely. A common pattern among contributors based in Sydney's inner west is to script the changes once after a fresh install, dropping a small bash file into ~/bin that reassigns audio, video, and image types in a single run. An IT volunteer helping out at a community centre in Hobart might keep a single mimeapps.list on a USB stick and drop it into each new install to standardise behaviour across the lab.
Editing .desktop Files for Permanent Associations
When the same application handles many formats, editing its .desktop file can be cleaner than running xdg-mime for every MIME type. These files live in /usr/share/applications/ for system packages, in /var/lib/flatpak/exports/share/applications/ for Flatpak installs, and in ~/.local/share/applications/ for anything user-specific. Each one contains an Exec line that points to the binary, an Icon line, and crucially a MimeType= field listing every type the app claims to handle.
Adding a type to that field is enough to make the application appear in the "Open With" menu. To make it the default, however, you need an additional line: X-GNOME-DefaultApplications= followed by a semicolon-separated list of MIME types. This pattern is read by the MIME database at session start and tells the system which desktop file to prefer for each type, and it is the same convention used by upstream GNOME.
A practical example is a custom Markdown viewer. By copying its .desktop file into ~/.local/share/applications/ and appending X-GNOME-DefaultApplications=text/markdown;, you ensure that every .md file opens in your preferred editor without further tweaking. The Australian Cyber Security Centre's small business guides suggest similar patterns for standardising software across teams, and the same approach scales from a single laptop to a multi-seat office. Be careful when editing system files, since package upgrades can overwrite them, so the recommended path is to copy the file to your local applications directory first.
AppImage, Flatpak Overrides and the User Local Layer
Modern Linux apps rarely come from a single source, and elementary OS reflects that reality in its MIME handling. AppImages are self-contained executables that do not register themselves with the system database at all. To make a portable app the default for a file type, you must add a desktop file by hand. Drop a MyTool.desktop file into ~/.local/share/applications/, point its Exec= line at the AppImage path, and list the relevant MIME types under MimeType=. From that moment the entry behaves like any other.
Flatpaks are a little different. They ship their own desktop files and MIME caches, but they are scoped through portals and may not see every file on disk. If a Flatpak refuses to open a file even after you have set it as default, the cause is usually the filesystem permission granted to the Flatpak, not the MIME configuration. Flatseal, a graphical tool for adjusting Flatpak permissions, can resolve most of these cases by giving the app access to the folders it needs. Snap packages face similar considerations, although elementary OS does not ship with snapd enabled by default. Users who add snapd manually inherit the same override rules as Flatpaks, with the Snap Store version of an app typically taking precedence over its Debian counterpart.
Browser Links, Email and Custom URL Schemes
File associations are only half the story. Elementary OS also routes URL schemes through the same MIME database, which is what allows a click on a mailto: link in any application to open your default email client, or a click on an https:// link to launch your browser. These associations live alongside the file-type handlers in mimeapps.list, but they use scheme entries such as x-scheme-handler/https and x-scheme-handler/mailto.
To find or change your browser default, run xdg-mime query default x-scheme-handler/https and set it with xdg-mime default firefox.desktop x-scheme-handler/https. The same approach works for ftp, ssh, irc, and any other scheme you want to claim. Users who follow niche online resources, for example anyone reading house edge for baccarat on a regular basis, will appreciate the option to lock their preferred browser as the default for every web link regardless of which app surfaces it.
Flatpak browsers, including the official builds of Firefox and Chromium, register their handlers through the portal system rather than the traditional mimeapps.list. They usually work without extra configuration, but if a link still opens in the wrong browser, clearing the override and re-selecting the Flatpak entry from "Open With" tends to reset the route. Elementary OS's Settings panel exposes the default browser under "Applications", which is the simplest way to set the initial value before reaching for the terminal.
Resetting Defaults and Recovering From Mistakes
Mistakes happen, and a misconfigured mimeapps.list can leave you opening text files in an image editor or PDF documents in a music player. The fastest recovery is to delete or rename the offending entry in ~/.config/mimeapps.list, then log out and back in. The session re-reads the file, and the system defaults return.
For a fuller reset, the update-desktop-database and update-mime-database commands rebuild the caches. Running them after a bulk edit forces the system to re-index every .desktop file and MIME definition, which clears out stale references. The commands are safe to run as a regular user, only touch cache files in ~/.cache and /var/cache, and are idempotent. The same pair of commands is also useful after installing a new version of GNOME or a major Flatpak runtime, when the cache can occasionally lag behind the new entries.
If a particular Flatpak is persistently grabbing every file type it can, Flatseal lets you revoke its ability to declare MIME handlers, which keeps the app installed but stops it from elbowing its way into every "Open With" menu. This is a useful trick on shared family machines, where a child installing a game bundle should not accidentally change the default PDF reader for everyone else in the household. For most users, a one-time tidy-up after the initial setup phase is enough, and only major app changes will require a quick revisit.
For anyone ready to go further, the natural next step is to script a small defaults.sh file that captures every MIME override you care about and run it after each fresh install. Store the file on a cloud drive backed by Australian-hosted infrastructure, drop it on a USB stick, or keep it in a private Git repository, and you can rebuild a familiar desktop in minutes on any new machine without retracing the right-click dance.