6

I want to open a PDF file from terminal. I only know the command xdg-open file-name.xxx to open a file. But once I use this command, it opens the PDF file with the Document Viewer application (Evince).

How to open a file from terminal with a non-default application (specifically a PDF with Master PDF Editor)?

3 Answers 3

6

Master PDF Editor provides a binary that you can use to open a file from the terminal. Supposing that you have installed the latest version of Master PDF Editor (version 5.9.40 currently), the binary is masterpdfeditor5, so you can open a PDF file using:

masterpdfeditor5 /path/to/file.pdf
5

Typically, an application will allow to open a file from the command line by providing the file name as an argument to the command for running the application. I am not familiar with the proprietary application "Master PDF Editor", but for many applications, it can simply work like:

  • Evince, the default PDF viewer in the standard Ubuntu desktop:

    evince /path/to/file.pdf

  • Gedit, the default text editor

    gedit /path/to/file.txt

etc. 99% chance that this also works this way for "Master PDF Editor", but it is ultimately a feature of the application.

4

Other answers have shown how to do this, but I'll explain how you can do this for any program. Assuming you have Master PDF editor installed, it'll probably be on your path. You can start typing a command in the terminal and hit Tab to get autocomplete. For example, I typed master and then hit Tab, and it completes to masterpdfeditor4 (I have an older version). It might also give you multiple options if there are more than 1 programs that start with master.

In general, programs also respond to -h or --help by printing a help message. For example:

masterpdfeditor -h

yields:

Master PDF Editor 4
Build 4.3.89, Based on Qt 5.4.1, 64 bit
Not Registered version.
Copyright 2018 Code Industry Ltd.
http://code-industry.net

usage: masterpdfeditor4 file.pdf -p 2

Allowed options:
-p                          : the page number of the document to display
--help, -h                  : show this output

Some programs also respond to man <program_name> but Master Pdf Editor evidently doesn't.

1
  • 1
    Sometimes <program_name> is not oubvious, for example it's evince for Document Viewer. On my system, they are joined in the /usr/share/applications/evince.desktop file. If needed, ask a separate question about searching in. desktop files.
    – pts
    Commented Mar 24, 2023 at 8:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .