How to Change Default Apps in Ubuntu?

Changing the default application for specific file types in Ubuntu allows you to customize your workflow and ensure your preferred software opens your files automatically. Whether you want to switch your default web browser, media player, or text editor, Ubuntu provides both a graphical user interface (GUI) and command-line methods to achieve this. This guide covers how to change default applications globally through the system settings, configure them for individual file extensions using the file manager, and manage them via the terminal for advanced users.

Method 1: Using Ubuntu System Settings

The quickest way to change the default applications for major categories—such as your web browser, email client, calendar, music, videos, and photos—is through the core system settings.

  1. Open the Settings application by clicking the system menu in the top-right corner of your screen and selecting the gear icon, or by searching for “Settings” in the Activities overview.
  2. Scroll down the left sidebar and click on Default Apps.
  3. You will see a list of categories (Web, Mail, Calendar, Music, Video, Photos). Click the dropdown menu next to the category you wish to change.
  4. Select your preferred application from the list of installed software. The change is applied immediately.

Method 2: Using the Files Manager (Nautilus) for Specific File Types

If you want to change the default program for a specific file extension (for example, making all .pdf files open with VLC instead of the default Document Viewer, or opening .py files with a specific code editor), use the file manager.

  1. Open the Files application and locate a file with the extension you want to change.
  2. Right-click on the file and select Properties from the context menu.
  3. In the properties window, click on the Open With tab at the top.
  4. Review the list of recommended and alternative applications. Select the application you want to set as the new default.
  5. Click the Set as Default button in the bottom-right corner of the window. All files sharing that specific extension will now open with your chosen program.

Method 3: Using the Command Line (Advanced)

For users who prefer the terminal or are managing a headless Ubuntu server, default applications can be configured using the mimeapps.list configuration file or the xdg-mime tool.

Using xdg-mime

To change the default application for a specific MIME type, you first need to know the MIME type of the file and the name of the application’s .desktop file.

To find the MIME type of a file, run:

xdg-mime query filetype filename.pdf

(This will output something like application/pdf)

To set the default application (for example, setting Evince as the default PDF viewer), run:

xdg-mime default evince.desktop application/pdf

Using update-alternatives

For system-level command-line tools (like changing the default terminal text editor from Nano to Vim), Ubuntu uses the alternatives system. Run the following command and follow the on-screen prompts to select your preference:

sudo update-alternatives --config editor