Fix: Default PDF Viewer Won't Change in Linux
Can't change your default PDF viewer in Linux? It's usually a MIME type or desktop file issue. Here's how to fix it fast.
Quick answer
Run xdg-mime default your-viewer.desktop application/pdf in the terminal. Then test with xdg-open test.pdf. If it doesn't stick, check ~/.config/mimeapps.list for duplicate entries.
Why this happens
I've been running help desks for years, and this one trips up even seasoned Linux users. The problem isn't that Linux can't change default apps — it's that there's a layer of configuration files that override the GUI settings. When you right-click a PDF and pick "Open With" > "Set as default," the desktop environment writes to ~/.config/mimeapps.list or ~/.local/share/applications/mimeapps.list. But if another tool (like a browser, a Flatpak, or an old config) wrote to ~/.config/mimeapps.list with different priorities, your choice gets ignored.
This often happens after installing a new PDF reader — Say you installed zathura or okular — and the desktop tries to keep the old default. Or worse, a Flatpak version of Evince overrides the system one.
Fix steps
- Identify the desktop file name for your preferred PDF viewer. Open a terminal and look in
/usr/share/applications/or~/.local/share/applications/. For example, for Zathura, it'szathura.desktop. For Okular,org.kde.okular.desktop. - Set the default with xdg-mime:
xdg-mime default your-viewer.desktop application/pdf - Update the MIME cache (this is the step most people skip):
update-desktop-database ~/.local/share/applications/ - Test it:
If it opens with the right viewer, you're done. If not, move to the next step.xdg-open test.pdf
If the main fix doesn't work
Check for a Flatpak or Snap override
Flatpak apps don't play nice with the system MIME database. If your preferred viewer is installed via Flatpak, run:
flatpak --user override --file-application=application/pdf your.viewer.id
Replace your.viewer.id with the app's reverse domain name like org.gnome.Evince. Snap users: check snap connections for the pdf-viewer slot.
Edit mimeapps.list manually
Open ~/.config/mimeapps.list in a text editor. Look for a line like:
application/pdf=evince.desktop
Change it to your viewer's desktop file. Also check ~/.local/share/applications/mimeapps.list — that file can override the global one. Delete any duplicate entries for application/pdf.
Reset the system-wide default
If you're on a shared system or a weird distro (I'm looking at you, Ubuntu with GNOME), run:
sudo update-alternatives --config x-www-browser
Wait, that's for browsers. For PDFs, there's no equivalent. But you can check /etc/xdg/mimeapps.list — if it's there and has a PDF entry, comment it out or delete it.
Prevention tip
After you get the right viewer set, lock it down. Create a file ~/.local/share/applications/mimeapps.list (if it doesn't exist) and put only the PDF line in it. This file has higher priority than ~/.config/mimeapps.list. Also, when you install a new PDF reader, don't click "Set as default" in the GUI during the first launch — it often writes conflicting entries. Stick with the terminal command xdg-mime default every time.
One more thing: if you're using a browser like Firefox that has its own PDF viewer, that's separate from the system default. Firefox ignores xdg-mime. You have to go into Firefox settings > General > Applications > PDF > select "Use other" and pick your viewer. Annoying, I know, but that's where the browser takes over.
Remember: xdg-mime is your friend. Most GUI tools are wrappers around it, and they often mess up. Direct control always wins.
Was this solution helpful?