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


7 Answers 7


xdg-open <URL> is the command you're looking for.


sensible-browser but as per sensible-browser(1), it only works properly on Debian or if the BROWSER environment variable is set. There’s also an open but stale MR in the sensible-utils repository to respect Ubuntu’s xdg-settings.

  • What about the differences between sensible-utils package and the system of alternatives found in /etc/alternatives and modified by update-alternatives?
    – enzotib
    Commented Oct 19, 2010 at 12:59
  • 13
    For me sensible-browser opens Opera instead pf default Chrome. xdg-open works as expected.
    – incrop
    Commented Jun 17, 2014 at 15:12
  • 3
    what @Incrop said is still true for Ubuntu 16.04, this opens Firefox instead of my default browser Chromium. Commented Mar 16, 2017 at 10:58
  • 6
    sensible-browser doesn't follow user preference configured in unity-control-centre. xdg-open does. Commented Feb 5, 2018 at 0:58
  • 2
    Although my default (gnome) browser is Firefox, sensible-browser opens Chrome.
    – alfC
    Commented Jan 20, 2020 at 5:31

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.

  • 1
    what does xdg stand for? Its hard to remember without knowing that.
    – Thupten
    Commented Jul 13, 2014 at 14:42
  • 4
    XDG stands for X Desktop Group aka freedesktop.org
    – Luca
    Commented Jul 13, 2014 at 19:05
  • Still still works on a default Ubuntu 16.04 installation. Commented Mar 16, 2017 at 11:20
  • 3
    if the user once configured to open html files with a text editor by default, this will not work. OP asks for a way to open the web browser, not the default application for html files (even though by default it's the same)
    – phil294
    Commented Jun 29, 2017 at 16:48
  • This will work on any gnu/linux distro that has x-server window manager (that is just about all of them - eg debian, *buntu, fedora, manjaro, Arch etc)
    – flurbius
    Commented Dec 27, 2017 at 19:58

You can also use:

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

And it will open the URL in the default browser.

  • 2
    for me, in Ubuntu 16.04, this will open Firefox even though Chromium is set as the default browser in the "Default Applications" setting. Commented Mar 16, 2017 at 10:56
  • this one opens chrome despite another browser is the default Commented Dec 5, 2020 at 13:32
  • Command not found. Commented Mar 7, 2023 at 13:35

Just that you may find it useful. A fallback approach, and a one-liner:

URL="https://www.url.com/some"; xdg-open $URL || sensible-browser $URL || x-www-browser $URL || gnome-open $URL

You can also add the following function to your system (your shell script, .bashrc, .zshrc, alias or functions files, ...):

function openUrl() {
   local URL="$1";
   xdg-open $URL || sensible-browser $URL || x-www-browser $URL || gnome-open $URL;

and you use as:

openUrl www.wikipedia.com

Good reading for the no familiar with the logical operators https://www.howtogeek.com/269509/how-to-run-two-or-more-terminal-commands-at-once-in-linux/.

; => run in all cases,

|| => run if the precedent command failed (or)

&& => run only if the precedent command succeed


var=someval -> set a variable

$var -> invoke the variable

  • 1
    Consider explaining what this command does so that others that see this know more about your answer. Links are good, but you need to ensure the key content of the link is in your answer if it is part of your answer (incase the link dies in the future). Commented Apr 18, 2019 at 3:23
  • 1
    @Zzzach...done! and i get the point. Though it was a simple matter. Commented Apr 18, 2019 at 3:31
  • this one is nice Commented Dec 5, 2020 at 13:34

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

gnome-open http://askubuntu.com
  • 4
    With default Ubuntu setup, sensible-browser and xdg-open commands work as well. Commented Oct 19, 2010 at 12:38
  • 1
    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 Commented Oct 21, 2010 at 18:19
  • 7
    @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. Commented Aug 22, 2011 at 14:37
  • 2
    gnome-open is dependent on gnome desktop, better off using xdg as its more common
    – flurbius
    Commented Dec 27, 2017 at 19:59
  • 1
    gnome-open is not installed by default lately.
    – alfC
    Commented Jan 20, 2020 at 5:33

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:

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). )

  • 2
    I wouldn't recommend editing /usr/bin/sensible-browser as this answer recommends. This change will be overwritten on a system upgrade. Commented Feb 21, 2014 at 11:53
  • rather than try to install a modified script on a users system, a more realistic solution is to use xdg-open as per Luca's answer. If you specify a html file or a URL it WILL open the browser - if you supply something else it will open an appropriate application for that type of resource. I doubt there is any good reason to open some file with a browser when it will be better handled by some other application, either by default or in accordance with the users explicit choice. If you must, you can force the browser to open it with x-www-browser (see Benjamin's answer)
    – flurbius
    Commented Dec 27, 2017 at 20:34

On Raspberry Pi Ubuntu I did this to start a webpage, fullscreen (in Kiosk mode) on startup:

# put in ~/.bash_profile
DISPLAY=:0 chromium-browser --app=https://your.website —kiosk &

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .