In most popular Linux distributions, such as Ubuntu, RedHat, Fedora, etc., there is a default installation of Firefox (a free and open-source browser), which is excellent and can seamlessly work most of the time.
If you have installed a different browser, such as Chrome (which provides a great experience, especially for those using Google products) or Tor Browser (which provides a secure way to browse the internet), you can also easily use them. However, your default Firefox browser will launch when you open a link or HTML file.
It can be annoying, so stick with this article to learn different ways to change your default web browser on Ubuntu or other Linux distros running on GNOME, KDE, or XFCE via CLI and GUI methods.
Changing Default Web Browser on Ubuntu (GUI/CLI)
There are two methods to change your default browser: either via GUI or CLI (which works only for the Xorg display server). You can use either of these methods based on your preferences, but before proceeding, make sure your desired browser, which you want to set as the default, is already installed on your system.
Once you've installed your desired browser, you can proceed with one of the following methods:
Method 1: Change Default Browser via GUI
This method involves following a simple step in the DE settings to change the default browser. Unlike CLI, this method is best suited for all users, as the same method can easily work for Wayland or Xorg desktop sessions.
So, depending on the distribution and desktop environment you are using, follow one of the following methods:
For GNOME
Open "Settings" and navigate to "Default Applications".
Next to "Web", click on the drop-down menu that lists all the installed and configured browsers on your system, and choose the one you want to set as the default; for me, it's Chrome.
For KDE Plasma
Users using KDE Plasma can also change their default browser as easily as shown in the GNOME method. Simply open "System Settings", navigate to "Applications", and then "Default Applications".
Next to "Web browser", click and select your desired browser that you want to set as the default, then click on the "Apply" button in the bottom right corner.
For XFCE
If you're using the XFCE desktop, open the "Application Finder" and search for "Default Applications".
In the "Default Applications" window, you'll find the "Web Browser" section. Under its drop-down menu, choose the browser you want to set as the default.
Method 2: Change Default Browser via CLI
If you want to change your default browser setting from your terminal, you can do so too, but note that as of writing this article, this method will only work with Xorg display sessions.
So, if your system is running on it, then you first need to locate the .desktop
file of your desired browser that you want to set as the default.
- ls /usr/share/applications/ | grep "browser-name"
Output:
Now, copy the name of the browser desktop file from the output and replace <browser-name.desktop>
with the copied desktop file name in the following xdg-settings
command:
- xdg-settings set default-web-browser <browser-name.desktop>
Output:
Once you have finished, you can execute the following command to verify your system's existing default browser.
- xdg-settings get default-web-browser
Output:
As you can see, changing the default browser on Linux is as simple as on any other operating system.