← 返回命令列表

Linux command

update-desktop-database 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Update the MIME type cache

sudo update-desktop-database

Update cache for a specific directory

update-desktop-database [path/to/applications]

Update in quiet mode

update-desktop-database -q

Update with verbose output

update-desktop-database -v

Update after installing a new .desktop file

sudo update-desktop-database /usr/share/applications

说明

update-desktop-database builds a cache database of MIME types handled by desktop files. The cache contains a mapping between MIME types and the desktop files (applications) that can handle them. This cache enables applications to quickly find which programs can open files of a specific MIME type without parsing every .desktop file on the system. The cache is stored in mimeinfo.cache within each applications directory. If no directory is specified, the command processes desktop files in the standard XDG data directories ($XDG_DATA_DIRS/applications), typically /usr/share/applications and /usr/local/share/applications. The command should be run after installing, removing, or modifying .desktop files to ensure the MIME type associations are current. Package managers typically run this automatically during software installation.

参数

-q, --quiet
Do not display any information about processing and updating progress.
-v, --verbose
Display detailed information about processing and updating progress.
-h, --help
Display help message and exit.

FAQ

What is the update-desktop-database command used for?

update-desktop-database builds a cache database of MIME types handled by desktop files. The cache contains a mapping between MIME types and the desktop files (applications) that can handle them. This cache enables applications to quickly find which programs can open files of a specific MIME type without parsing every .desktop file on the system. The cache is stored in mimeinfo.cache within each applications directory. If no directory is specified, the command processes desktop files in the standard XDG data directories ($XDG_DATA_DIRS/applications), typically /usr/share/applications and /usr/local/share/applications. The command should be run after installing, removing, or modifying .desktop files to ensure the MIME type associations are current. Package managers typically run this automatically during software installation.

How do I run a basic update-desktop-database example?

Run `sudo update-desktop-database` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -q, --quiet do in update-desktop-database?

Do not display any information about processing and updating progress.