Starting files directly from the command line in Ubuntu

In Window, at the command line, you can type start index.html and it will open a web browser and load and display the page. This works for all registered filetypes. (e.g. PDFs, jpg …)

In Linux the same thing is possible, but the mechanism’s different.

If you’re using a gnome-based desktop (e.g. Ubuntu), add this:

# Open files and folders directly from the command line
# e.g. gnome-open README.PDF
# which with this alias becomes: g README.PDF
# This also works with folders
# e.g.  g .      will open the current folder

alias g='gnome-open'

either directly to the end of ~/.bashrc or preferably, create a new file called .bash_aliases and put it in there.

Thanks to

Instead of gnome-open, a possibly better way is to use xdg-open. I think this works on many desktops but I’m vague on the details. It certainly works in KDE.

This entry was posted in Computing and tagged , , . Bookmark the permalink.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>