通过 CLI 设置文件类型的默认应用程序?

use*_*897 13 defaults debian mime-types libreoffice file-types

尽管安装了 LibreOffice Calc,但我有 150 台 Debian Jessie 机器在双击时会在 Gnumeric 中打开 ODS 文件。我知道可以通过右键单击 ODS 文件并从“属性”窗口更改其默认程序来更改此设置,但无法让 150 个用户执行此操作。他们都使用 xfce4 和 thunar。

我需要通过 CLI 执行此操作,以便我可以远程跨所有工作站执行此操作。我看过的/usr/share/applications~/.local/share/application/mimetypes.list没有运气-文件前相比并通过GUI改变之后在这里没有发现变化。

默认情况下,如何使用 bash 使这些工作站通过 LibreOffice Calc 打开 ODS 文件?

编辑:与此问题的答案不同,我的 Jessie 安装没有~/.config/mimeapps.list/usr/share/applications/defaults.list

GAD*_*D3R 11

您可以使用mimeopenwith-d选项:

man mimeopen

DESCRIPTION
   This script tries to determine the mimetype of a file and open it with
   the default desktop application. If no default application is
   configured the user is prompted with an "open with" menu in the
   terminal.


-d, --ask-default
       Let the user choose a new default program for given files.
Run Code Online (Sandbox Code Playgroud)

例子:

mimeopen -d file.mp4
Run Code Online (Sandbox Code Playgroud)

示例输出:

Please choose a default application for files of type video/mp4

   1) VLC media player  (vlc)
   2) Other...
Run Code Online (Sandbox Code Playgroud)

验证一下:

xdg-open file.mp4
Run Code Online (Sandbox Code Playgroud)