I am beginning to learn and love ubuntu. Is there any way to open files like .pdf, .jpeg, .odt, .docx etc. using command line?

For instance, I have a pdf named: 9949107741MathFormulas.pdf in the following directory:


when I go to above directory type 9949107741MathFormulas.pdf to open it, I get the message:

9949107741MathFormulas.pdf: command not found

Please advise, how can this task be accomplished?

  • Would you do the same thing in any other OS? Just type in a filename and hit enter? – user25656 Jul 22 '13 at 14:44

You fist need to ask the application to open it. For pdf, you can call "evince".

Example command:

evince example.pdf
  • Thanks, now I understand. Do I need to close this question, if so, how can it be done? – Jitendra Jul 22 '13 at 14:19
  • don't have to do anything... This is a possible duplicate of How to open a PDF file from terminal?. You did your part. – Meintjes Jul 22 '13 at 14:29

I know you already accepted an answer but I think it will be better if you know that this has been discussed in the past with better answers like this one, which I reproduce right here for you.

xdg-open file.dvi

xdg-open will open any file with its default application. As a bonus, you can close the terminal without killing the application.

Since xdg-open is quite a long name, I put an alias for it in .bashrc:

alias go='xdg-open'

This way you don't need to know what application open this file or another. xdg-open will invoke whatever software is related to the file contents or extension.

Don't forget to give credit to Mihai Capotă for his good answer.

Good luck!

Not the answer you're looking for? Browse other questions tagged or ask your own question.