Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I was wondering what's the terminal command to open the default web browser.

share|improve this question
    
which browser web browser,file browser,which one ?? –  Open Help Oct 19 '10 at 10:42
    
post corrected. –  Luca Oct 19 '10 at 10:44

5 Answers 5

up vote 25 down vote accepted

sensible-browser is the command you're looking for.

share|improve this answer
6  
Thanks! I also found the more general xdg-open. –  Luca Oct 19 '10 at 10:55
    
What about the differences between sensible-utils package and the system of alternatives found in /etc/alternatives and modified by update-alternatives? –  enzotib Oct 19 '10 at 12:59
1  
For me sensible-browser opens Opera instead pf default Chrome. xdg-open works as expected. –  incrop Jun 17 at 15:12

Searching on Google I found the answer.

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 a file is provided the file will be opened in the preferred application for files of that type. xdg-open supports file, ftp, http and https URLs.

xdg-open is part of xdg-utils package and it's already installed on Ubuntu 10.10.

share|improve this answer
    
what does xdg stand for? Its hard to remember without knowing that. –  Thupten Jul 13 at 14:42
    
XDG stands for X Desktop Group aka freedesktop.org –  Luca Jul 13 at 19:05

You can also use:

x-www-browser http://some-url.org

And it will open the URL in the default browser.

share|improve this answer

With default Ubuntu setup only gnome-open command comes to mind.

gnome-open http://askubuntu.com
share|improve this answer
3  
With default Ubuntu setup, sensible-browser and xdg-open commands work as well. –  marenostrum Oct 19 '10 at 12:38
    
The advantage is that you can use gnome-open for almost all file-types, URIs and directories. It's one command to learn, instead of trying to remember about obscure commands like sensible-browser –  Stefan Lasiewski Oct 21 '10 at 18:19
3  
@Stefan Lasiewski: xdg-open should do the same thing - actually, it will call gnome-open, or kde-open, or whatever, depending on your desktop environment. Thus it's more portable. –  Piskvor Aug 22 '11 at 14:37

I played around this a little. There is a problem with gnome-open — it won't invoke the default web browser unless you specify a url. That's a problem if you want to set up an icon or a shortcut that will always launch the browser that is set as default. Other times you might need to set it as a parameter for some programs that require a link to a web browser and don't work well with gnome-open (e.g.: acroread). You might solve this by using either x-www-browser or gnome-www-browser system links that you can set up through update-alternatives, but those are system wide settings, not user specific (and they are not synchronized with the values set through gnome-default-applications-properties. All this can be solved by opening the sensible-browserexecutable (which is actually a script):

sudo gedit $(which sensible-browser)

and adding this at the beginning:

#!/bin/bash
BROWSER=$(gconftool -g /desktop/gnome/url-handlers/http/command)
export BROWSER="${BROWSER//"\"%s\""/}"

That will make sensible-browser always launch the user-specified default web browser. (I found out that gnome-default-applications-properties changes some gconf keys according to the browser that is currently set. The default browser value can be obtained from any of these keys so I went for /desktop/gnome/url-handlers/http/command and used it to fill the $BROWSER variable (the value is stripped of the "%s" part). )

share|improve this answer
1  
I wouldn't recommend editing /usr/bin/sensible-browser as this answer recommends. This change will be overwritten on a system upgrade. –  Gilles Feb 21 at 11:53

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.