Howto Open a PDF file under Linux / FreeBSD

PDF is an acronym for Portable Document Format. It is a proprietary file format developed by Adobe Systems for representing two-dimensional documents in a device independent and resolution independent format. You can open pdf file using graphical as well as command line tools (i.e. without GUI). Linux supports following PDF viewer under X window:

  • Gnome pdf viewer (gpdf)
  • KDE pdf viewer (kpdf)
  • xpdf
  • Official Adobe acrobat reader

Graphic pdf viewer under Linux/FreeBSD

If you are using Gnome desktop…

Open a shell prompt and type the command:
$ gpdf file.pdf
$ evince file.pdf

If you are using KDE desktop…

Open a shell prompt and type the command:
$ kpdf file.pdf

You can also click on K icon > Select Graphics > Select PDF viewer

Console pdf viewer under Linux/FreeBSD

Console pdf viewer

As far as I know there is no console based PDF viewer exists. But you can use the following trick to open a PDF file:

a) First install pdftohtml – A command-line tool for converting pdf-files into html and other formats.

Debian User install pdftohtml using following command:
# apt-get install pdftohtml
Red Hat / Fedora user install pdftohtml using following command:
# yum install pdftohtml
FreeBSD user install pdftohtml using following command:
# pkg_add -v -r pdftohtml
OR use ports collection:
# cd /usr/ports/textproc/pdftohtml
# make; make install

The idea is very simple you will use a pdftohtml program to convert a PDF file into html, xml and png images and then display them using text browser such as elinks or lynx. This is useful when you works on remote server or if GUI is not available:
For example to convert CH09.PDF file you need to type the following set of commands:
$ pdftohtml CH09.PDF
$ lynx CH09.html

$ elinks CH09.html

You can also convert a PDF file to text file using following command:
$ pdftotext CH09.pdf
$ vi CH09.txt

See also

=> You can get Official Adobe acrobat reader here for UNIX/Linux oses.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 15 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
15 comments… add one
  • Lego Nov 16, 2009 @ 15:07

    For RHEL5 gpdf is obsolete. You now use evince.


  • Igor Ganapolsky Dec 3, 2009 @ 5:06

    Great advice. I now use KDE and couldn’t figure it out until I read your article.

  • sunardo Mar 23, 2010 @ 3:57

    In Linux C programming how to open a pdf file with default reader?

    thanks for advance…

    • Ankie May 11, 2013 @ 17:54

      xdg-open file.dvi

      • SRIKANTH POLISHETTI Nov 7, 2016 @ 15:30

        thaks.., but how to close the file i mean the command for closing

  • tagnu Sep 24, 2010 @ 14:53

    Thank you for intro to pdftohtml .

  • Ritwick Feb 28, 2011 @ 17:34

    Thanks buddy..!!!

  • Deepak Pandit Jun 16, 2011 @ 17:06

    great article

  • shivangpatel Sep 20, 2012 @ 18:51

    there is no any other way to open .pdf file in terminal? without converting file???

    • Deepak Sep 21, 2012 @ 11:26

      You need not convert pdf to view it

      On the terminal type the following command
      user$ evince .pdf

      This opens up the pdf for you to view

      • shivangpatel Oct 30, 2012 @ 19:29

        but it’s open Document viewer…. i wan’t to show pdf complite on terminal… It’s possible?

        • Laszlo Blanar Dec 7, 2012 @ 14:31

          $ pdftotext file.pdf –

  • Godefroy Jun 19, 2014 @ 15:57

    I’m using Putty and I want to display the PDF file, Which command will I use?
    Thank you

  • Pullua Oct 28, 2014 @ 8:30

    thanks, good work!

  • Callista Graves May 30, 2017 @ 19:50

    less name-of-pdf-.pdf > name-of-pdf-.txt

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum