Read more

Linux: Open a file with the default application

Henning Koch
March 02, 2016Software engineer at makandra GmbH

If you are on a Linux shell and want to open a file with whatever default application is configured for that type, this often works:

xdg-open Quote.odt
xdg-open invoice.pdf
xdg-open index.html

Pro Tip

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show snapshot

Make an alias so you have a simpler API (like Mac OS): alias open=xdg-open or alias x=xdg-open.


You can choose your "Default applications" via UI in the Ubuntu "Settings" application (gnome-control-center). This is just a very rough setting (e.g. open Photos with Shotwell Viewer).

If a certain file type (or better mime type) should be opened with a different application, this can be set via command line:

# Query the default application:
xdg-mime query default $(xdg-mime query filetype <file>)

# Override the default application for this filetype with:
mimeopen -Dd <file>

Changed mime default are stored in ~/.config/mimeapps.list (and sometimes ~/.config/*-mimeapps.list).

Further reading

Posted by Henning Koch to makandra dev (2016-03-02 15:37)