1.相关配置文件
全局配置
/etc/gnome/defaults.list
/usr/share/applications/mimeinfo.cache
个人配置
~/.local/share/applications/mimeapps.list
~/.local/share/applications/mimeinfo.cache
2./etc/gnome/defaults.list部分内容
[DefaultApplications]
application/csv=openoffice.org-calc.desktop
application/excel=openoffice.org-calc.desktop
application/msexcel=openoffice.org-calc.desktop
application/msword=openoffice.org-writer.desktop
application/ogg=totem.desktop
application/pdf=evince.desktop
application/postscript=evince.desktop
application/rtf=openoffice.org-writer.desktop
application/tab-separated-values=openoffice.org-calc.desktop
application/vnd.lotus-1-2-3=openoffice.org-calc.desktop
application/vnd.ms-excel=openoffice.org-calc.desktop
application/vnd.ms-word=openoffice.org-writer.desktop
application/vnd.rn-realmedia=totem.desktop
text/plain=gedit.desktop
3./usr/share/applications/mimeinfo.cache部分内容
[MIMECache]
text/plain=gedit.desktop
application/vnd.ms-excel.template.macroenabled.12=openoffice.org3-calc.desktop
audio/x-s3m=gnome-mplayer.desktop
application/vnd.ms-word=openoffice.org3-writer.desktop
application/x-lzma=file-roller.desktop
video/x-mng=gnome-mplayer.desktop
image/x-portable-bitmap=f-spot-view.desktop;eog.desktop;
x-directory/normal=nautilus-folder-handler.desktop
image/x-dcraw=f-spot-view.desktop
4.更改文件默认打开方式
案例:更改文本文件的默认打开方式从gedit改为gvim
(1). 修改/etc/gnome/defaults.list文件
text/plain=gedit.desktop
改为:
text/plain=gvim.desktop
(2).修改/usr/share/applications/mimeinfo.cache文件
text/plain=gedit.desktop
改为:
text/plain=gvim.desktop
一般程序的快捷方式存放在/usr/share/applications目录下这些时已经安装好的应用程序,有的时候,我们使用的应用程序是解压缩后直接使用的,比如大名鼎鼎的文本编辑器Sublime Text2.
5.另外一种解决方案
右击文件 --> 属性,在打开方式页中修改即可。
6.注意
网上有很多帖子都是只提到了/etc/gnome/defaults.list这个文件,而没有提到/usr/share/applications/mimeinfo.cache这个缓存文件,结果当然是修改无效咯。
当然,如果你把缓存文件删除也行。