Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is pretty simple:

Is there a command I can use in bash that will open a specific URL in the default browser?

share|improve this question
up vote 32 down vote accepted

There's a command that knows about your default browser:


This will also work for every other type of URI (Uniform Resource Identifier), like images - which will automatically open with eog, openoffice documents, and so on, and also on filesystem paths (xdg-open /tmp/foobar.png).

There is also



xdg-mime query default text/html

To find out what application is going to be used.

You can set your preffered application by going to System → Preferences → Preferred Applications:

alt text

These utilities are part of the specification, so you can use them in your applications - and it's going to work on all of the desktops that adhere to the spec.

share|improve this answer

You can use xdg-open like so:


From the XDG-OPEN man page:

xdg-open opens a file or URL in the user's preferred application. If a URL is provided the URL will be opened in the user's preferred web browser.

share|improve this answer

gnome-open works as well as xdg-open but neither knows what to do with naked domain.

So gnome-open works but not gnome-open

Here is a small function to make it easier to type and accept the stripped down domain name.

function go { gnome-open http://$1 ; }

Paste the above in your command line, hit enter and try it out. If you like it you can save it to your .bash_aliases or .bashrc file, then source ~/.bash_aliases (assuming it is in your home directory) and it will be persistent for that session and all new sessions.

So now we just type go and wallah!

share|improve this answer

Using x-www-browser URL will open the browser or a new tab at the given URL

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.