Apt-file 命令

OS: Debian based systems
Wiki: apt-file-debianWiki

使用場景

當遇到“某某某命令是在那個包裏的”,或者“我要找某某命令應當下載那個軟件包”的時候可以用到這個命令。

比如說,我想要啓動qt配套的 qt-designer 和 qt-assistant,然後命令行給我報錯,提示:

➜ assistant 
assistant: could not exec '/usr/lib/qt5/bin/assistant': No such file or directory
➜ designer
designer: could not exec '/usr/lib/qt5/bin/designer': No such file or directory

碰到這種情況,我可以使用 apt-file 命令來查找這個二進制文件在哪個包裏面出現,比方說:

➜  apt-file search bin/assistant
qt5-assistant: /usr/lib/qt5/bin/assistant 
qt5-assistant: /usr/lib/x86_64-linux-gnu/qt5/bin/assistant
qtchooser: /usr/bin/assistant

(qtchooser只是一個wrapper,用於啓動sdk中的幫助,而剩下的是真正的二進制程序)

(其實sdk裏面已經包括了designer和assistant, 有qt creator的同學不用費勁去下載這兩個了)

安裝方式

可以使用apt 安裝

sudo apt update -y
sudo apt install apt-file -y

安裝完畢之後還需要通過apt-file更新一下數據庫,讓apt-file有對apt數據庫的訪問權限。(建議每次使用前都更新一下)

sudo apt-file update

其他用法

根據 wiki , apt-file還存在一個被動模式,可以被dpkg調用(好像是), 使用 dpkg -S 加上 文件名 來查詢。

➜  dpkg -S libmp3lame.so.0
libmp3lame0:amd64: /usr/lib/x86_64-linux-gnu/libmp3lame.so.0

官網提示:dpkg -S 的方案只能查詢本地 package , 而 apt-file 可以聯網查詢所有安裝和未安裝的 package.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *