Linux
13 March 2011 3 Comments

Ubuntu: Opening Files with the Default Program From a Terminal

Say you want to open a PDF file (myDocument.pdf) through the terminal of the Ubuntu desktop environment. On Windows you would just type the name of file, and Windows finds the program assigned to the PDF extension. On Ubuntu you can type

evince myDocument.pdf

Where evince is the name of the PDF document viewer on Ubuntu. However, it is easier to use the program that Ubuntu’s desktop environment has assigned to the extension:

xdg-open myDocument.pdf

This way you don’t have to find the name of the appropriate binary.

Note
In older versions of Ubuntu this might not work. The gnome-open command can be used instead.
Tags: evince, , gnome-open,

3 Responses to “Ubuntu: Opening Files with the Default Program From a Terminal”

  1. iamagui 13 September 2011 at 4:39 pm #

    Hi there,
    This is the first page for google search ‘document viewer ubuntu command’. And the command ‘gnome-open’ is an awesome, excellent command. Many thanks for command, much appreciate it.

    Reply
    • tboerman 22 September 2011 at 10:23 pm #

      Glad to hear you found your answer!

      Reply
  2. JuniorSRR 23 October 2012 at 10:48 pm #

    Five stars!

    Reply