Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

3 Answers

up vote 11 down vote accepted

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

xdg-open http://google.com

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-email team@stackexchange.com

and

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 freedesktop.org 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:

xdg-open http://askubuntu.com/

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

Make it easy: Just add Wine to your Ubuntu installation. After that, when you try to open a *.url file the first time with Firefox (which is the standard web browser of the current Ubuntu distro) chose "open with Wine program starter" and make that option the default. From then on Ubuntu Firefox will open any *.url quite like Firefox under MS Windows is doing it since the beginning of time. (Hello Firefox: when will Debian / Ubuntu Firefox open *.url files without Wine as Windows Firefox does ?).

share|improve this answer
This question is about how to be able to specify a URL to be opened, not about how to open a .url file. (Also, you can simply associated .url files with Firefox or whatever other browser you want--it's not necessary to install Wine for this.) – Eliah Kagan Jul 13 '12 at 17:47
hello Eliah: Did you ever try this ? To associate *.url files to Ubuntu Firefox, Midori or other Linux versions web browser without prior installation of Wine into Ubuntu will result in opening (nearly) endless empty tabs. Other Linux distros (such as Puppy !) behave better. – Ann Jul 13 '12 at 19:33

Your Answer

 
discard

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.