I used to work on the Mac terminal before and I used:

open file2open.pdf

and the PDF file would be opened on preview or whatever my default viewer was. When I use it in the terminal in Ubuntu I get this error message:

Couldn't get a file descriptor referring to the console
  • 26
    Ubuntu is not Mac (just pointing that out).
    – RolandiXor
    May 16, 2011 at 21:24
  • 2
    @Roland but mac claims to be a unix based system, so I assumed the terminal would behave the same atleast
    – yayu
    May 16, 2011 at 22:47
  • 17
    Linux is not Unix.
    – RolandiXor
    May 17, 2011 at 0:44
  • 23
    Linux is what Unix wanted to be, when it was growing up.
    – david6
    Nov 20, 2011 at 21:51
  • 1
    You can use fbi (Linux frame buffer image viewer) apt-get -y install fbi fbgs arch.pdf man fbgs for color and resolutions.
    – user195833
    Sep 24, 2013 at 21:45

13 Answers 13


Most desktop environments on modern systems (generic)

open file2open.xxx


xdg-open file2open.xxx    


  • until Xenial (16.04):

    gvfs-open file2open.xxx
  • starting with Artful (17.10):

    gio open file2open.xxx

(xxx = some file extension). With this command the default app for xxx will be invoked (for example evince if you want to open PDF).


  • Using Evince, GNOME’s default document viewer:

    evince file2open.pdf
  • Using Okular, KDE’s default document viwer:

    okular file2open.pdf
  • 1
    So there is absolutely no way to view the text of a pdf file inside the terminal? With the pictures removed or converted to ASCII art?
    – Vorac
    Nov 14, 2013 at 12:27
  • 8
    That is another question. You can view with less. Example: less my-file.pdf
    – desgua
    Nov 16, 2013 at 21:34
  • 2
    when using evince your document closes after you close the terminal. xdg-open per the elmicha's answer worked wll for me.
    – Jon49
    Oct 30, 2014 at 4:11
  • 1
    For gnome (3) this needs libgnome2-bin which is not installed by default.
    – Lode
    Nov 17, 2015 at 13:57
  • 1
    evince file2open.pdf is simple way for the same.
    – Vikrant
    Mar 9, 2017 at 7:01

You can also use:

xdg-open foo.pdf

xdg-open works in Gnome, KDE, xfce, LXDE and perhaps on other desktops.

You can put an alias in your ~/.bash_aliases:

alias open=xdg-open
  • 2
    +1. This is what chrome for one uses. It supports URIS as well (e.g. xdg-open irc://...). Pretty cool.
    – crazy2be
    May 16, 2011 at 23:59
  • 3
    this is the proper answer not the one above, and this will work with all modern DEs.
    – OneOfOne
    May 17, 2011 at 4:57

For all those lost Mac users in Ubuntu-land ..

Edit your .bashrc file, and add:

alias open='gnome-open'

Then you can just use:

open file2open.pdf
  • Does not work on Linux Mint with Cinnamon. `xdg-open' is the way to go.
    – Cain
    Aug 4, 2017 at 2:07
  • on mint either xdb-open file.pdf or xreader file.pdf
    – zzapper
    Nov 26, 2017 at 22:34

if the pdf is simple...

pdftotext -layout file2open.pdf - | more

We can use this in text mode, ssh, etc.


If you want to view PDF within Terminal (Command Line Interface), try to use zathura.

Install Zathura sudo apt-get install zathura -y.

To view a PDF file just run => zathura /path/to/xxx.pdf

BTW: zathura requires X11 anyway, it doesn't work on Servers with no X installed.

  • Works great and still nicely updated on github.
    – james-see
    Nov 12, 2018 at 2:00
  • zathura doesn't display in the current terminal (Gnome), but opens its own window? A GTK application?
    – user598527
    Jun 2, 2022 at 9:20

if you have Document Viewer installed type the following command:

evince Name_of_pdf_file

if it is not already installed you can install it firstly using the following command:

sudo apt-get install evince
  • 1
    You could add on how to install it when it isn't
    – MadMike
    Oct 23, 2014 at 9:51

You can also use

ooffice filename.pdf

to open your file in open office.


The Z shell (zsh) has suffix based alias (-s), these allow you to set up a file association between a file extension like .jpg and a suitable application like xreader:

alias -s pdf='xreader'

With an alias like that you just need to type the file name and hit ↵ Return, e.g.:

  • The zsh shell has suffix based alias (-s) these allow you to set up a file association between a file extension e.g. jpg and a suitable application say xnview
    – zzapper
    Nov 27, 2017 at 8:29

In Ubuntu 17.04 you case use this:

gio open <file.pdf>

  • the command gio is not available in Ubuntu, at least on 16.04 Jan 30, 2018 at 12:58

I personally use a shell script:

$ cat pdf
#! /bin/bash

gnome-open ${1:-*.pdf}

When you call pdf it will open all pdfs in the current directory, specify which pdf by supplying an argument. I have many directories containing but one pdf file (e.g. so many LaTeX directories) so only having to write pdf saves me quite some time and keystrokes.


You can define the following function in your ~/.bashrc

open () {
     read -p "Enter File Name: " ; xdg-open "$REPLY"
  • open () { read -p "Enter File /location/Name: " ; ''xdg-open $REPLY'' }
    – user277818
    May 4, 2014 at 13:07

Too open with Libre office use:

loffice <file.pdf>


soffice <file.pdf>


Goplay -

gooffice <file.pdf>

You can also type:

firefox file_name.pdf

This will open your pdf in firefox browser.

You must log in to answer this question.

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