Open a file or directory from the terminal

There are a few tools that open a file or a directory from the terminal. This commands can be very usefull and easy to use, if you alias them.

  • gnome-open /path/to/file_or_dir
  • xdg-open /path/to/file_or_dir
  • okular /path/to/file_or>dir

Because okular belongs to KDE environment, you may not have it installed, if you are using gnome.

Install okular:

  • In Debian / Ubuntu / Linux Mint : sudo apt-get install okular
  • In Fedora / CentOS : sudo yum install okular
  • openSUSE : sudo zypper install okular

Alias these commands, to type less:

alias go='gnome-open &> /dev/null &'

OR:

alias go='xdg-open &> /dev/null &'

OR:

alias go='okular &> /dev/null &'

I have redirected the stdout and the stderr to /dev/null (thrown them away) and used the & character to send the process into background.

$ go .
$ go /etc/passwd

Liked it? Take a second to support Geekster on Patreon!
Tagged with: , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Support LinuxG via Patreon
Support LinuxG.net on Patreon!
Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!