Open PDF file in Linux using command line

I am working on a shell script. It visit a webpage and download a pdf file in /tmp/ called bill-09-01-2020.pdf. Once stored I need my Linux script to do as I want. I want to Open PDF file in Linux using my script. How can I it be done?

You can use the following commands to open PDF file in Linux:

  1. evince command - GNOME document viewer. It
  2. xdg-open command - xdg-open opens a file or URL in the user’s preferred application.

Open PDF file in Linux using evince

The syntax is:

evince filename.pdf
evince ~/Downloads/data.pdf

Open PDF file in Linux using xdg-open

Try it as follows

xdg-open file.pdf
xdg-open /path/to/file.pdf

# Download a pdf using the wget in /tmp/ and open it #
cd /tmp/
wget https://url/foo.pdf
xdg-open foo.pdf

FYI, both of them can open other files such as images, URLs, documents and more. Read about them by typing the man command:

man evince
man xdg-open

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki