46

When we want to open an application or file from the terminal, we type, say,

okular file.dvi

This opens the application, but also shows the status of the application. We cannot close the terminal, because it kills the process. Unfortunately, if you're trying to, for example, create a LaTeX file, you will need one tab for the text editor, one for the dvi file, and so on. And if you're trying to open all windows from the terminal, you can forget it. I'm trying use the terminal as much as possible, and while I have Yakuake, it is still a bother having so many tabs and seeing which of those have an application I've killed and so on.

So, is there a way to open an application/file from the terminal so that the status doesn't show and immediately gives the prompt so that we can use it to open more applications?

Seth
  • 59,332
notablytipsy
  • 2,927

4 Answers4

80
open file.dvi

Starting with Ubuntu 22.04, open is a link to xdg-open.

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

For older Ubuntu versions, use xdg-open directly:

xdg-open file.dvi

Or add an alias in .bashrc:

alias open='xdg-open'
18
okular file.dvi &

just append an & to make your command running as separate process.

user827992
  • 2,901
14

okular file.dvi &> /dev/null & would be a bit better. This way, the program does not write to the terminal.

If you use just okular file.dvi & the program will still report things on the terminal, often in the middle of your work

josinalvo
  • 7,017
6

With, say, evince file.pdf &, closing the terminal will still close the process, so that it is still a child process of the terminal and has no independence of it; nohup evince file.pdf & will allow you to close the terminal without the program closing as nohup means that any signals for the process to close (hangup) will be ignored. You can also disown a process in a similar way, see this discussion here.