Command to open a URL

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 [email protected]

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.


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.


If you don't necessarily want to use the default browser, you can call any browser program directly and give the URL as argument, for example:

chromium-browser https://youtube.com

or

firefox https://youtube.com

Tags:

Command Line