命令搜索包名

摘要:
本手册简要介绍了在Linux中查找提供特定文件的包的安全不同方法。当您手动编译和安装容量时,这可能有用。当您从源代码编译包时,可以使用

This brief tutorial explains a few different ways to find the package that provides a specific file in Linux. This could be useful when you manually compile and install a package. When you’re compiling a package from source, there are chances that you may receive an error something like “No rule to make target ‘<somefile>’, needed by ‘<somefile>’. Stop.”. You may not know exactly which packages provides the missing file. In such cases, you can easily find out the packages that provides those missing files and install them in your Linux box as described in this guide.

Find The Package That Provides A Specific File In Linux

Arch Linux, Antergos, Manjaro Linux:

On Arch-based, there is a small command line tool called pkgfile, which is used to search files from packages.

Pkgfile comes pre-installed with Arch Linux. If it’s not, you can install using the following command:

$ sudo pacman -S pkgfile

Then, run the following command to sync with pkgfile database:

$ sudo pkgfile -u

Now, you can find the package that provides a specific file, say for example alisp.h, using command:

$ pkgfile alisp.h
extra/alsa-lib

As you see in the above output, alsa-lib package provides alisp.h file. And, the package is available from extra repository. You can now install this package as shown below.

$ sudo pacman -S alsa-lib

To list all files provided by the alsa-lib package, run:

$ pkgfile -l alsa-lib

RHEL, CentOS, Fedora:

In YUM-based systems such as RHEL and its clones like CentOS, Scientific Linux, you can find the package that owning a particular file, using the following command:

$ yum whatprovides '*filename'

On Fedora, use the following command instead:

$ dnf provides '*filename'

If the file is already available in your system, say for example /bin/ls, you can then find the package that owns the file using command:

# rpm -qf /bin/ls
coreutils-8.22-18.el7.x86_64

You can also use the repoquery command as follows:

$ repoquery -f /bin/ls

If repoquery command is not available in your system, install yum-utils package.

$ sudo yum install yum-utils

Or,

$ sudo dnf install yum-utils

Debian, Ubuntu, Linux Mint:

In any DEB-based systems, you can find the package that provides a certain file using apt-file tool.

Install apt-file as shown below if it’s not installed already:

$ sudo apt-get install apt-file

If you just installed apt-file, the system-wide cache might be empty. You need to run ‘apt-file update’ as root to update the cache. You can also run ‘apt-file update’ as normal user to use a cache in the user’s home directory.

Let us update the database cache using command:

$ sudo apt-file update

And, then search for the packages that contains a specific file, say alisp.h, with command:

$ apt-file find alisp.h

Or,

$ apt-file search alisp.h

Sample would be:

libasound2-dev: /usr/include/alsa/alisp.h

Well, libasound2-dev it is! You can install this package using command:

$ sudo apt-get install libasound2-dev

If you already have the file, and just wanted to know which package it belongs to, you can use dpkg command as shown below.

$ dpkg -S $(which alisp.h)

Or,

$ dpkg -S `which alisp.h`

If you know the full path of the file, say for example /bin/ls,  you can search for the packages it belongs to using the following command:

$ dpkg -S /bin/ls
coreutils: /bin/ls

SUSE / openSUSE:

On SUSE and openSUSE, run the following command to find out which package a certain file belongs to.

$ zypper wp alisp.h

Or,

$ zypper se --provides --match-exact alisp.h

Suggested read:


And, that’s all. Hope this helps. If you know any other methods to find to find the package that contains a particular file, feel free to let us know in the comment section below. I will check and update the guide accordingly.

免责声明:文章转载自《命令搜索包名》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇DigitalOcean(DO)购买VPS流程12、MyBatis教程之缓存下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Linux查看系统信息的一些命令及查看已安装软件包的命令

系统 # uname -a # 查看内核/操作系统/CPU信息 # head -n 1 /etc/issue # 查看操作系统版本 # cat /proc/cpuinfo # 查看CPU信息 # hostname # 查看计算机名 # lspci -tv...

Linux下常见命令

Linux下常见命令原文地址:http://www.cnblogs.com/Gaojiecai/archive/2011/11/03/2234888.html =============安装和登陆命令======================================== Mount:挂载命令。把存储介质指定成系统中的某个目录,比如挂载光驱mo...

Docker打包python flask服务

1、将宿主机上python环境保存到requirements.txt pip3 freeze >requirements.txt 2、新建sources.list文件(apt的源文件) sources.list具体内容如下: $ vi sources.list deb-src http://archive.ubuntu.com/ubuntu x...

Ubuntu Linux系统下aptget命令详解

常用的APT命令参数:apt-cache search package 搜索包apt-cache show package 获取包的相关信息,如说明、大小、版本等sudo apt-get install package 安装包sudo apt-get install package - - reinstall 重新安装包sudo apt-get -f in...

ALSA声卡07_分析调用过程_学习笔记

1、编译新的strace工具分析aplay和amixer应用程序对声卡的调用过程 (1)因为旧的strace工具不能识别不能识别alsa声卡驱动程序里面的ioctrl. (2)编译过程参考http://blog.csdn.net/qingkongyeyue/article/details/52228729 (3)出现错误 需要建立相关的设备节点 播放声...

基于ALSA的WAV播放和录音程序

http://blog.csdn.net/azloong/article/details/6140824 这段时间在探索ALSA架构,从ALSA Core到ALSA Lib,再到Android Audio System。在看ALSA Lib时,写了一个比较典型的基于ALSA的播放录音程序。程序包包含四个部分: WAV Parser是对WAV文件的分析和封装...