怎样在 Ubuntu 中修改默认程序
Ubuntu 默认程序
![](/data/attachment/album/201607/28/094309t2dc9cunmcl90dtc.jpg)



> 
> 简介: 这个新手指南会向你展示如何在 Ubuntu Linux 中修改默认程序
> 
> 
> 


对于我来说，安装 [VLC 多媒体播放器](http://www.videolan.org/vlc/index.html)是[安装完 Ubuntu 16.04 该做的事](/article-7453-1.html)中最先做的几件事之一。为了能够使我双击一个视频就用 VLC 打开，在我安装完 VLC 之后我会设置它为默认程序。


作为一个新手，你需要知道如何在 Ubuntu 中修改任何默认程序，这也是我今天在这篇指南中所要讲的。


### 在 Ubuntu 中修改默认程序


这里提及的方法适用于所有的 Ubuntu 12.04，Ubuntu 14.04 和Ubuntu 16.04。在 Ubuntu 中，这里有两种基本的方法可以修改默认程序：


* 通过系统设置
* 通过右键菜单


#### 1.通过系统设置修改 Ubuntu 的默认程序


进入 Unity 面板并且搜索<ruby> 系统设置 <rp>  （ </rp> <rt>  System Settings </rt> <rp>  ） </rp></ruby>：


![](/data/attachment/album/201607/28/094340on9sbt9rvm58f1n9.jpeg)


在<ruby> 系统设置 <rp>  （ </rp> <rt>  System Settings </rt> <rp>  ） </rp></ruby>中，选择<ruby> 详细选项 <rp>  （ </rp> <rt>  Details </rt> <rp>  ） </rp></ruby>：


![](/data/attachment/album/201607/28/094406faeqxjxbgqljewq2.jpeg)


在左边的面板中选择<ruby> 默认程序 <rp>  （ </rp> <rt>  Default Applications </rt> <rp>  ） </rp></ruby>，你会发现在右边的面板中可以修改默认程序。


![](/data/attachment/album/201607/28/094429eva3pxpwe27npzdd.jpeg)


正如看到的那样，这里只有少数几类的默认程序可以被改变。你可以在这里改变浏览器、邮箱客户端、日历、音乐、视频和相册的默认程序。那其他类型的默认程序怎么修改？


不要担心，为了修改其他类型的默认程序，我们会用到右键菜单。


#### 2.通过右键菜单修改默认程序


如果你使用过 Windows 系统，你应该看见过右键菜单的“打开方式”，可以通过这个来修改默认程序。我们在 Ubuntu 中也有相似的方法。


右键一个还没有设置默认打开程序的文件，选择“<ruby> 属性 <rp>  （ </rp> <rt>  properties </rt> <rp>  ） </rp></ruby>”


![](/data/attachment/album/201607/28/094451le8sh2hxz8xi5b8e.png)


*从右键菜单中选择属性*


在这里，你可以选择使用什么程序打开，并且设置为默认程序。


![](/data/attachment/album/201607/28/094512bpv8h58c4i13zipy.png)


*在 Ubuntu 中设置打开 WebP 图片的默认程序为 gThumb*


小菜一碟不是么？一旦你做完这些，所有同样类型的文件都会用你选择的默认程序打开。


我很希望这个新手指南对你在修改 Ubuntu 的默认程序时有帮助。如果你有任何的疑问或者建议，可以随时在下面评论。




---


via: <https://itsfoss.com/change-default-applications-ubuntu/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 译者：[Locez](https://github.com/locez) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
**Brief**: This beginner’s guide shows you **how to change the default applications in Ubuntu** Linux.

Installing [VLC media player](http://www.videolan.org/vlc/index.html) is one of the first few [things to do after installing Ubuntu 18.04/19.10](https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/) for me. One thing I do after installing VLC is to make it the default application so that I can open a video file with VLC when I double click it.

As a beginner, you may need to know how to change any default application in [Ubuntu](http://www.ubuntu.com/) and this is what I am going to show you in this tutorial.

But before we do that, I recommend that you also read my guide on [how to install/remove software in Ubuntu](https://itsfoss.com/remove-install-software-ubuntu/) – in case you’re still confused about that.

## Changing default applications in Ubuntu

There are basically two ways you can change the default applications in Ubuntu:

- via system settings (valid for changing the default web browser, email client, calendar, music application, video player and image viewer)
- via right-click menu (valid for applications other than the above mentioned ones)

If you prefer videos, you can watch the video below:

### 1. Change default applications in Ubuntu from System Settings

Simply head to the System **Settings**:

![System Settings Pop Os](https://itsfoss.com/content/images/wordpress/2020/01/system-settings-pop-os.jpg)

In the System Settings, click on the **Details** option:

![System Details Pop Os](https://itsfoss.com/content/images/wordpress/2020/01/system-details-pop-os.jpg)

Now, click on the “**Default Applications**” option as highlighted in the screenshot below:

![Default Applications Pop Os](https://itsfoss.com/content/images/wordpress/2020/01/default-applications-pop-os.jpg)

As you can see, there are only a few kinds of default applications that can be changed here. You can change the default applications for web browsers, email clients, calendar apps, music, videos and photo here. What about other kinds of applications?

Don’t worry. To change the default applications not listed here (for instance – text editor), we’ll use the option in the right-click menu.

### 2. Change default applications in Ubuntu from right-click menu

Let’s say you have a [markdown](https://itsfoss.com/best-markdown-editors-linux/) file (.md) which opens in Gedit text editor by default. But you want to use some other applications to open markdown files. Here’s what you need to do.

Right click on the file and then select **Open with Other Application**:

![Changing Default Application Ubuntu via right click menu](https://itsfoss.com/content/images/wordpress/2016/07/changing_default_application_ubuntu_1.png)

If you don’t see your choice of application, click on the **View All Applications**:

![Changing Default Application Ubuntu](https://itsfoss.com/content/images/wordpress/2016/07/changing_default_application_ubuntu_3.jpg)

Locate the desire application and select it:

![Changing Default Application Ubuntu](https://itsfoss.com/content/images/wordpress/2016/07/changing_default_application_ubuntu_4.jpg)

This will open the file in your chosen application.

The thing here is that the file manager automatically recognizes your choice and the next time you double click on the file to open it, it will open it with the application you last chose.

![Default Application Changed in Ubuntu](https://itsfoss.com/content/images/wordpress/2016/07/changing_default_application_ubuntu_2.jpg)

Keep in mind that this behavior is not applicable to web browsers, music players, video players, email clients, calendars and photo viewer. For that you need to use the first method described here.

If you want to [change the default terminal emulator, the steps are entirely different](https://itsfoss.com/change-default-terminal-ubuntu/).

## Troubleshoot: Application not available in ‘open with’ list

In some rare cases, the application may not even be available in the list of open with applications.

I encountered this issue with Pinta a few years back and here’s what I did to fix it.

To add any program in the list of the open with applications, open a terminal and use the following command:

`sudo gedit /usr/share/applications/XXX.desktop`


Please note two things. In XXX.desktop, XXX is the name of your application. And then use of gedit. You can use any other editor. I used Vim. If you use Gedit, it will dispaly some warning messages in the terminal but will open the file in a GUI.

In this desktop file, look for a line that looks like this:

`Exec=XXX`


If you have something like this, replace this line with:

`Exec=XXX %F`


Save it and exit/close the desktop file. No need to restart or anything. It should be working instantly.

### Explanation

Now to explain what this %F means. %F is actually an [Exec Key](https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html). It means the program will be supplied with multiple file inputs at the same time ([arguments](https://en.wikipedia.org/wiki/Parameter_(computer_programming))). So if I have this %F set in Pinta, I can open multiple images in the same instance of Pinta (think it like tabs in a web browser). But the program must support this feature.

The question which you might be wondering why it was not showing in the list of applications before and why after adding %F, it is working. The reason is that when there is no such Exec Key, the program will not accept any argument, which means you can not “open with” a file with this application as “open with” supplies the file as the argument.

You can read more about Exec Key [here](https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html).

I hope you found this beginner’s tutorial to change default applications in Ubuntu helpful. If you have any questions or suggestions, feel free to drop a comment below.