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
Most desktop environments (generic)
GNOME (generic)
until Xenial (16.04):
starting with Artful (17.10):
(
xxx
= some file extension). With this command the default app forxxx
will be invoked (for example evince if you want to open PDF).Application-specific
Using Evince, GNOME’s default document viewer:
Using Okular, KDE’s default document viwer:
You can also use:
xdg-open works in Gnome, KDE, xfce, LXDE and perhaps on other desktops.
You can put an alias in your ~/.bash_aliases:
For all those lost Mac users in Ubuntu-land ..
Edit your .bashrc file, and add:
Then you can just use:
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.
if you have Document Viewer installed type the following command:
if it is not already installed you can install it firstly using the following command:
if the pdf is simple...
We can use this in text mode, ssh, etc.
You can also use
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 likexreader
:With an alias like that you just need to type the file name and hit ↵ Return, e.g.:
In Ubuntu 17.04 you case use this:
gio open <file.pdf>
I personally use a shell script:
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 writepdf
saves me quite some time and keystrokes.