Set Default Applications per File Type (xdg-mime)
Use xdg-mime default to choose which app opens a MIME type such as PDF, and query commands to discover types and current defaults.
Run `xdg-mime default okularApplication_pdf.desktop application/pdf` to make Okular the default PDF viewer.
01Command
Command
$ xdg-mime default okularApplication_pdf.desktop application/pdf02What it does
First find the exact MIME type with `xdg-mime query filetype file.pdf`, then the .desktop name of the app you want from /usr/share/applications. The setting is per-user (stored in ~/.config/mimeapps.list) and applies to GNOME, KDE and XFCE alike; verify with `xdg-mime query default application/pdf`. Repeat for other types like text/plain or image/png to build up your preferred defaults.
03Risk
!Warning: The .desktop filename must match a real installed application — a typo makes xdg-mime accept it but double-click then does nothing or falls back to the previous app.
04Undo
Undo
$ xdg-mime default evince.desktop application/pdf05Sources
- xdg-mime(1) - Linux manual pageEvidence: xdg-mime default sets the default application for a MIME type, and xdg-mime query filetype/default reports the MIME type and current default handler.
Last verified: 2026-09-18 · Category: System & Settings