rap*_*ink 127
注意:在下面的命令中,以“root#”开头的命令表示需要以root身份运行。
要查找软件包安装了哪些文件,请使用dpkg -L
:
$ dpkg -L $package
Run Code Online (Sandbox Code Playgroud)
apt-file
可以在安装之前告诉您软件包将安装哪些文件:
root# apt-get install apt-file
root# apt-file update
$ apt-file list $package
Run Code Online (Sandbox Code Playgroud)
或者,如果您已经在.deb
本地将包作为文件,则可以dpkg
在其上运行:
$ dpkg --contents $package.deb
Run Code Online (Sandbox Code Playgroud)
要查找哪个包提供了系统上已有的文件,请使用:
$ dpkg -S /path/to/file
Run Code Online (Sandbox Code Playgroud)
要查找哪个包提供了当前不在您系统上的文件,请apt-file
再次使用:
$ apt-file search /path/to/file
Run Code Online (Sandbox Code Playgroud)
这是一个可以为您完成此操作的函数,而无需将包下载到磁盘。该解决方案也不需要任何第三方程序(如 apt-file)或最低 debian/ubuntu 安装之外的任何程序。
\n# Function that gets the package layout of a remote package from \n# apt/apt-get/aptitude/synaptic/etc...\napt_list () \n{\n # Build array of packages \n local packages=("$@");\n # Iterate package indexes up to the length of the array minus 1\n for pkg in $(seq 0 1 $((${#packages[@]}-1)));\n do\n # Pretty little separator in case you are examining the \n # contents of multiple packages.\n echo -e "\\n#### ${packages[$pkg]} ####\\n";\n # Pipe steps (in order)\n # Print the url to the .deb package remote location from sources.list\n # delimit by single quotes and select only the url\n # pipe the url to xargs after a curl silent follow redirects \n # insecure (no cert checking some may wish to take the -k off \n # the curl command.\n # use dpkg -c to check the contents of the downloaded package in stdin\n # Use perl to remove dots after modification timestamp on sysroot\n apt-get download -o Dir::Cache::archives="./" --print-uris ${packages[$pkg]}\\\n | awk -F\\\' \'{print $2}\' | xargs -I \'{}\' curl -skL \'{}\' |\\\n dpkg-deb -c /dev/stdin | perl -ne \'s,(:\\d\\d )[.]/,$1/,g;print\';\n # Line break so the last package name doesn\'t wind up on same line as PS1\n echo;\n # end loop\n done\n}\n
Run Code Online (Sandbox Code Playgroud)\n然后使用apt_list <package name1> [package name 2]
例如\napt_list curl wget
关于您的第二个问题,您可以使用dpkg -S /path/to/isntalled/file
或者如果您尝试使用 . 查看已下载/本地 .deb 文件的内容dpkg --contents </path/to/deb/file>
。至于从不知道拥有该文件的包的名称的包中反向检查文件,第三方解决方案apt-file(一个软件包,可以对可用存储库中的包内容进行索引,并允许您搜索对于所有可用包中的特定文件),可用。这就像yum provides
基于 rhel 的系统(如 CentOS)是最好的选择。
\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b
\n