User Agents

Web browsers and everyday web tech, explained

Change Default Browser on Linux: Step-by-Step

· 5 min read · Settings and Privacy

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Changing the default browser on Linux determines which browser opens when you click a link in an email, a chat app, or a document. The process varies slightly depending on your desktop environment (GNOME, KDE, XFCE, etc.), but the core steps are similar. This guide covers the most common methods, including graphical settings and command-line tools, so you can set your preferred browser as the system default.

What You'll Need

  • A Linux desktop environment (GNOME, KDE Plasma, XFCE, Cinnamon, etc.)
  • The browser you want to set as default must be installed (e.g., Firefox, Chrome, Chromium, Brave, Vivaldi)
  • Access to a terminal (for the command-line method) and sudo privileges if you need to change system-wide settings

Step-by-Step

Method 1: Using Desktop Settings (GUI)

  1. Open the system settings. Look for an app called "Settings," "System Settings," or "Preferences" in your application menu. The exact name depends on your desktop environment.
  2. Navigate to the default applications section. In GNOME, go to Settings → Default Applications. In KDE Plasma, go to System Settings → Default Applications. In XFCE, go to Settings → Preferred Applications. In Cinnamon, go to System Settings → Preferred Applications.
  3. Find the "Web Browser" or "Internet Browser" dropdown. It is usually at the top of the list.
  4. Select your desired browser from the dropdown. If your browser is not listed, choose "Custom" or "Other" and browse to the executable file (e.g., /usr/bin/firefox or /usr/bin/google-chrome).
  5. Close the settings window. The change is saved automatically. Test by clicking a link in a non-browser app (like a text editor or email client) to confirm.

Method 2: Using xdg-settings (Command Line)

  1. Open a terminal. You can usually press Ctrl+Alt+T or search for "Terminal" in your app menu.
  2. Check the current default. Run xdg-settings get default-web-browser to see what is currently set.
  3. Set a new default. Run xdg-settings set default-web-browser [browser.desktop]. Replace [browser.desktop] with the correct desktop file name. For example, for Firefox it's firefox.desktop, for Chrome it's google-chrome.desktop, for Chromium it's chromium-browser.desktop or chromium.desktop. You can list available .desktop files in /usr/share/applications/ to find the exact name.
  4. Verify the change. Run xdg-settings get default-web-browser again to confirm the new default is set.

Method 3: Using update-alternatives (Debian/Ubuntu)

  1. Open a terminal.
  2. Run sudo update-alternatives --config x-www-browser. This command shows a list of installed browsers that are registered as alternatives.
  3. Enter the number corresponding to your preferred browser and press Enter.
  4. Optionally, do the same for gnome-www-browser if it exists, to cover both generic and GNOME-specific handlers.

Method 4: Setting Default in the Browser Itself

  1. Open your preferred browser.
  2. Go to the browser's settings. For Firefox, click the menu (three lines) → Settings. For Chrome/Chromium, click the three dots → Settings.
  3. Look for a "Default browser" section. It is usually under "General" or "On startup."
  4. Click the button that says "Make default" or "Set as default." This will invoke the system's default application handler and may open a confirmation dialog.
  5. Confirm the change in the dialog if it appears. The system will now recognize this browser as the default.

Common Mistakes

  • Choosing the wrong .desktop file name. For example, using chrome.desktop instead of google-chrome.desktop will fail. Always check the exact name in /usr/share/applications/.
  • Not having the browser installed system-wide. If you installed the browser as a Flatpak or Snap, the .desktop file might be in a different location (like /var/lib/flatpak/exports/share/applications/). You may need to use the GUI method or manually create a .desktop file.
  • Changing only the browser's internal setting. Some browsers have a "Set as default" button that only works if the system allows it. If you're on a restricted environment, you might need to use the system settings instead.
  • Forgetting to close and reopen applications. Some apps cache the default browser at startup. After changing the default, close and reopen the app you're testing with.

Tips

  • Use the GUI method first. It's the most reliable and user-friendly.
  • If you use multiple desktop environments, each one may store its own default. You may need to set the default in each environment you use.
  • For Flatpak browsers, you can use the command flatpak --user override --socket=x11 if the browser doesn't open correctly, but for default setting, use the GUI method.
  • Check the ~/.config/mimeapps.list file. This file stores user-level associations. You can edit it manually if needed, but it's safer to use the GUI tools.
  • Use xdg-settings for scripting. If you manage multiple machines, you can automate the default browser setting with a script.

Troubleshooting

  • The change doesn't stick after reboot. This can happen if a system update resets the defaults. Re-apply the setting after major updates. Also, check if you have a system policy that overrides user settings (e.g., in managed environments).
  • Links still open in the old browser. This usually means the application you're using has its own browser setting. For example, some email clients have a "Browser" option in their own preferences. Check the app's settings.
  • xdg-settings returns an error. If you get "xdg-settings: unknown command" or similar, ensure you have xdg-utils installed. On Debian/Ubuntu, install with sudo apt install xdg-utils.
  • The browser is not listed in the GUI dropdown. This happens if the browser's .desktop file is not in the standard location. Try reinstalling the browser or manually adding a custom entry in the GUI.
  • After using update-alternatives, the default doesn't change. Some desktop environments don't use the alternatives system. Use the GUI method or xdg-settings instead.

Frequently Asked Questions

How do I find the .desktop file name for my browser?

Look in /usr/share/applications/ for files ending in .desktop. For example, firefox.desktop, google-chrome.desktop, chromium-browser.desktop. If your browser is a Flatpak, check /var/lib/flatpak/exports/share/applications/.

Can I set a different browser for different users?

Yes, the default browser is stored per-user in ~/.config/mimeapps.list. Each user can set their own default without affecting others.

What is the difference between xdg-settings and update-alternatives?

xdg-settings is a freedesktop standard tool that directly edits the MIME associations. update-alternatives is a Debian/Ubuntu-specific system that manages symbolic links for commands like x-www-browser. Both can work, but xdg-settings is more universal.

Why does my browser's "Set as default" button not work?

Some browsers rely on the system to confirm the change. If the system doesn't show a confirmation dialog, the browser might not have permission. Use the system settings instead.

Does changing the default browser affect command-line tools like w3m or links?

No, those are terminal-based browsers and are not affected. The default browser setting only affects GUI applications that open web links.

Can I set a default browser that is not installed system-wide?

If you have a portable browser (e.g., downloaded as a tarball), you can create a .desktop file manually and place it in ~/.local/share/applications/, then set it as default.