Ubuntu equivalent of Yum's WhatProvides, to find which package provides a file
I believe apt-file will give you what you want.
$ apt-file update
$ apt-file list mysqladmin
kmysqladmin: /usr/bin/kmysqladmin
$ apt-file search mysqladmin
autoconf-archive: /usr/share/aclocal/ac_prog_mysqladmin.m4
autoconf-archive: /usr/share/autoconf-archive/html/ac_prog_mysqladmin.html
bash-completion: /etc/bash_completion.d/mysqladmin
kmysqladmin: /usr/bin/kmysqladmin
$ apt-file search mysqladmin
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_health.xml
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_startup_variables_description.dtd
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_startup_variables_description.xml
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_status_variables.xml
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_system_variables.xml
mysql-client-5.1: /usr/bin/mysqladmin
mysql-client-5.1: /usr/share/man/man1/mysqladmin.1.gz
mysql-cluster-client-5.1: /usr/bin/mysqladmin
mysql-cluster-client-5.1: /usr/share/man/man1/mysqladmin.1.gz
mysql-testsuite: /usr/lib/mysql-testsuite/r/mysqladmin.result
mysql-testsuite: /usr/lib/mysql-testsuite/t/mysqladmin.test
How to list the contents of a package using YUM?
There is a package called yum-utils
that builds on YUM and contains a tool called repoquery
that can do this.
$ repoquery --help | grep -E "list\ files"
-l, --list list files in this package/group
Combined into one example:
$ repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz
On at least one RH system, with rpm v4.8.0, yum v3.2.29, and repoquery v0.0.11, repoquery -l rpm
prints nothing.
If you are having this issue, try adding the --installed
flag: repoquery --installed -l rpm
.
DNF
Update:
To use dnf
instead of yum-utils
, use the following command:
$ dnf repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz
which libs are a header file belongs to
Use the package content search of your distribution, in this case you can find it here.
If you cannot find the filename through that search, it means there is no debian package providing it.
Bash script - determine vendor and install system (apt-get, yum etc)
You don't really need to check for vendor as they may decide to change packaging system (unlikely but conceptually, you would have to ensure that for each distro you test for, you try the right package manager command). All you have to do is test for the installation itself:
YUM_CMD=$(which yum)
APT_GET_CMD=$(which apt-get)
OTHER_CMD=$(which <other installer>)
and then possibly sort them in your preference order:
if [[ ! -z $YUM_CMD ]]; then
yum install $YUM_PACKAGE_NAME
elif [[ ! -z $APT_GET_CMD ]]; then
apt-get $DEB_PACKAGE_NAME
elif [[ ! -z $OTHER_CMD ]]; then
$OTHER_CMD <proper arguments>
else
echo "error can't install package $PACKAGE"
exit 1;
fi
you can take a look at how gentoo (or framework similar to yocto or openembedded) provide approach to even get the source code (with wget) and build from scratch if you want a failsafe script.
Can yum tell me which of my repositories provide a particular package?
yum list packagename
That will show from which repository the package is in the third column of the output.
For already installed packages, that won't work, as the third column shows just installed. In that case you can do e.g. rpm -qi packagename
, typically the Vendor, Packager and Build Host tags will give an indication to which repository the package belongs. Also it's quite common for some repo symbol being appended to the package version number.
Check RPM dependencies
In fact that's not a one but four different questions :).
*) First you can quickly list a downloaded package's dependencies/requirements by using the following commands:
$ rpm -qp mypackage.rpm --provides
$ rpm -qp mypackage.rpm --requires
*) Second, you can use yum
utility in order to satisfy these (somewhat cryptic) dependencies automatically (assuming that all your repositories are set up correctly, and all the dependencies are available):
$ sudo yum install mypackage.rpm
*) Third, there are several RPM search resources, some of them already suggested above. I'd like to list another one, just for the reference - pkgs.org.
*) Fourth, there is an additional popular repository for RHEL5 and RHEL6 distros - EPEL. Note that it's not supported by Red Hat.
Hope my answer(s) will help.
Related Topics
Difference Between .Dynamic .Dynsym and .Dynstr in an Elf Executable
How to Repeat a Dash (Hyphen) in Shell
Calculating Rounded Percentage in Shell Script Without Using "Bc"
Force Linux to Use Only Memory Over 4G
Run Command After 1 Hour in Linux
How to Do Versioning of Shared Library
How to Find the Inode of a Tcp Socket
List Files Recursively in Linux Cli With Path Relative to the Current Directory
How to Capture Network Frames in a Kernel Module
How Does Stat Command Calculate the Blocks of a File
Output the 2Nd Column of a File
Cannot Sudo Su Anymore, "No Tty Present and No Askpass Program Specified"
How to Read Data from Excel Sheet in Linux Using Shell Script
"Tput: No Value for $Term and No -T Specified " Error Logged by Cron Process
I Want to Use "Awk" or Sed to Print All the Lines That Start with "Comm=" in a File