Terminal question

image
Why does it not work

Don’t you need a pdf-viewer to view a pdf file?

For example
$ evince name-of-the-file.pdf

You have two problems in your command …

For one you can’t add filenames with space, it’s better practice to use dash or underscores. However, if you have space you can use brackets or / I think to avoid problems with blank space in file name. I generally begin typing the filename in the directory of interest and hit tab for autocomplete.

Something like that:

Also you may want to indicate with wich program to use to open your file. For example with okular you simply use okular file.pdf else your terminal doesn’t know which program to use, could be xed, inkscape or other.

1 Like

open is a MacOS command. It shouldn’t work on Linux distros (at least not without a plugin/ script)

To open files via a Linux terminal, you write name of application followed by the filename.

Of course, the application should be capable of opening given file/directory.

Eg

thunar ~/Desktop
mpv video.mp4
feh picture.png
zathura document.pdf
firefox endeavouros.com

… and so on. You can use any other application you like.

Also, as @Zircon34 mentions in last post, you either enclose filename/ filepath in quotes ( evince "~/my file name.pdf" ) or prefix spaces with \ . ( evince ~/my\ file\ name.pdf ).


Talking about open, the closest you can get on Linux without third party stuff is xdg-open. It is used pretty much the same way as open.

xdg-open ~/Desktop
xdg-open video.mp4
xdg-open picture.png
xdg-open document.pdf
xdg-open endeavouros.com

I’m not sure if open detaches process from terminal or not. xdg-open does not do that. You can achieve that using nohup.

nohup xdg-open ~/Desktop

Now, even if you close the terminal, your file manager won’t close.

4 Likes

Re. filenames in Linux:

1 Like

or alias open='xdg-open' ?

2 Likes

Nice to see someone using the terminal the proper way!

Edit your ~/.bashrc file and add this line to it:

alias open='xdg-open >/dev/null 2>&1'

Close and open your terminal. Then you can just:

open file.pdf

And it will be the same as opening it with your file manager of choice.

seems legit :wink:

2 Likes

Yeah, you don’t want any stdout or stderr polluting your terminal when you just want to open a file. :wink:

Linux is not unix! :wink:

:sponge: :bubbles: :broom:
exactly

1 Like

LNU/Ginux.

1 Like

@StarDust A practical solution to avoiding invalid paths/filenames on Linux is to use Tab-completion always. Try it by beginning to type a folder or file and press Tab on your keyboard as often as it takes to display the name you want, then continue typing and start tab-ing again. The more you type before tab-ing, the better precision tab completion has.

Yo this worked! Thanks everyone

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.