185

After I have installed a package by yum (with multiple repositories configured), how can I find from which repository it has been installed?

If I run yum info package-name (or yum list package-name), I can only see that the package is "installed".

techraf
  • 4,163
  • 8
  • 27
  • 44
lg.
  • 4,579
  • 3
  • 20
  • 20
  • 1
    Great question! I installed yum-utils and tried one it's utils called repoquery, but no luck. – Sean Staats Sep 03 '09 at 15:33
  • see also http://serverfault.com/questions/90409/how-can-i-verify-which-repository-a-package-resides-on-in-centos :) – warren Dec 03 '09 at 12:43
  • 1
    @warren your link is not useful because your link is a question about "what repo is an rpm stored in" but this question asks "what repo is an INSTALLED rpm from". different questions. – Trevor Boyd Smith Sep 07 '16 at 18:49
  • if you are used to doing `rpm -qa|grep NAME` then you can [do `yum list installed|grep NAME` to find what repo the rpm is from](http://unix.stackexchange.com/questions/22560/list-all-rpm-packages-installed-from-repo-x). – Trevor Boyd Smith Sep 07 '16 at 18:50
  • @TrevorBoydSmith - 7 years ago, it was close. Today, it's ***still*** similar. Never said it was the **same**. Just that it was related. – warren Sep 07 '16 at 18:50

15 Answers15

102

With yum-utils installed, repoquery will provide the information you seek (here 'epel' being the repository).

$ repoquery -i cherokee

Name        : cherokee
Version     : 0.99.49
Release     : 1.el5
Architecture: i386
Size        : 8495964
Packager    : Fedora Project
Group       : Applications/Internet
URL         : http://www.cherokee-project.com/
Repository  : epel
Summary     : Flexible and Fast Webserver
Description :
Cherokee is a very fast, flexible and easy to configure Web Server. It supports
the widespread technologies nowadays: FastCGI, SCGI, PHP, CGI, TLS and SSL
encrypted connections, Virtual hosts, Authentication, on the fly encoding,
Apache compatible log files, and much more.
pevik
  • 286
  • 1
  • 12
Xiong Chiamiov
  • 2,874
  • 2
  • 26
  • 30
  • 3
    repoquery does not seem to work right, i get different package versions then `yum info package_name`, it does not seem to query the repositories in the same order as yum. – Mike Miller Nov 30 '10 at 16:38
  • Same here on a few servers. `yum info package_name` returns more results than repoquery apparently. This is why stack exchange should not lock in votes. – reflexiv Dec 18 '12 at 05:51
  • 15
    I found Xiong Chiamiov's answer not correct. `repoquery -i $pkg` gives repo from which a `$pkg` is available, not the repo from which the `$pkg` was installed. I did that command and `rpm -qi $pkg` and got different version numbers. `rpm` resulted in an earlier version number than that of `repoquery`. –  Feb 13 '13 at 18:48
  • It's possible your local copy is out-of-date, or it was installed with additional commands to yum (e.g. `--use-mirror`). I don't think it's possible to *always* get the right answer. – Xiong Chiamiov Oct 05 '13 at 04:12
  • 2
    user158844 is right. This will tell you what repos provide a given package, but not what repo a specific package came from. If you installed a package from a certain repo, removed that repo, then installed another repo that provides a package with the same name, running 'repoquery -i' like this would return to you packages listing the newly installed repo, *not* the one that you actually installed the package from. The asker wants to know what package the installed software actually came from. Not what current repos happen to have packages with the same name. – Todd Walton Jun 12 '19 at 16:31
  • This answer is incorrect, as stated above it shows from where a package is available, not where it was installed from as asked. – M_dk Jul 09 '20 at 07:38
53

What version of yum?

On the current version if the installed package is the same version as the most recent one available then the repo it was installed from is shown.

$ yum info irssi
Installed Packages
Name       : irssi
Arch       : i586
Version    : 0.8.14
Release    : 1.fc11
Size       : 2.3 M
Repo       : installed
From repo  : updates
Summary    : Modular text mode IRC client with Perl scripting
URL        : http://irssi.org/
License    : GPLv2+
Description: Irssi is a modular IRC client with Perl scripting. Only text-mode
           : frontend is currently supported. The GTK/GNOME frontend is no
           : longer being maintained.

$ yum --version
3.2.23

If there is a newer package available, then it will be shown separately, with the new version showing the repo it's available from.

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
theotherreceive
  • 8,235
  • 1
  • 30
  • 44
25

Coming way to late but (at least on Fedora 15) one can use yumdb for similar queries:

yumdb info 'python*'

And what I actually needed to list packages from given repo(s):

yumdb search from_repo 'my-*-repo'
Martian
  • 1,060
  • 8
  • 8
14

If all else fails, you can inspect the yumdb manually. It's located in /var/lib/yum/yumdb and contains detailed information on every installed package. You'll be particularly interested in from_repo. For example, for the bind-utils package:

# for i in /var/lib/yum/yumdb/b/*bind-utils*/*; do echo $i: `cat $i`; done
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/checksum_data: 39f7840f93d3d76825a9e8da79cfe0366f7fad68f018a273477aee62cccfa3f4
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/checksum_type: sha256
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/command_line: install bind-utils
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/from_repo: updates
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/from_repo_revision: 1397654451
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/from_repo_timestamp: 1397654759
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/installed_by: 0
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/reason: user
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/releasever: 6

To get just the information you want:

# cat /var/lib/yum/yumdb/b/*bind-utils*/from_repo
updates

Later versions will provide even more data; for instance in EL 7 the exact mirror and URL from which the package was downloaded is stored here.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • +1. But it's even better to do something like: `for i in /var/lib/yum/yumdb/b/*bind-utils*/*; do echo $i: \`cat $i\` | grep -oP 'from_repo:\ \K.*'; done`, which in the above example returns: `updates` - much more readable! – Greg Dubicki Jan 27 '16 at 21:10
  • 1
    @GregDubicki The point of the command was to show more of the context of what is going on and how things are stored. It apparently failed to do so: There is no need to `grep` anything here, and you can even drop the loop. A very simple `cat /var/lib/yum/yumdb/b/*bind-utils*/from_repo` is all you need. – Michael Hampton Jan 27 '16 at 21:14
  • This is what I needed. I wanted to know whether an installed package was installed from a repo or a local package file, and this tells me that information. Thanks! – Warwick Jan 08 '20 at 22:02
  • Great answer! I used this to establish a unique list of what all repos were in use on a given server via: # for file in $(find /var/lib/yum/yumdb -name "from_repo" -print); do (cat "${file}"; echo); done | sort -u – Steve Bonds Jan 29 '20 at 19:44
6
rpm -qi packagename

Will tell you the vendor and packager

Esmail
  • 61
  • 1
  • 1
6

To see what installed from repo epel: (Should work under Centos 5.5) note, if you have no repo named epel, it will spit out everything installed.

repoquery --repoid=epel -a | xargs yum list installed
KyleMit
  • 488
  • 4
  • 9
  • 21
David A.
  • 61
  • 1
  • 1
  • 1
    This appears to work as long as there isn't an updated package in the repository. So you need to run yum update just before using it. – codewaggle May 29 '12 at 09:22
5

The simplest and most straightforward approach without installing any extra tools, greping or outputting extraneous information is simply:

yum list installed [package name]

The third column will provide the ID of the repository the package was installed from.

This was mentioned in a comment on the original question using grep, but that's not necessary. You can just pass the package name directly to yum to filter.

Scott Buchanan
  • 176
  • 1
  • 4
  • 1
    Caveat! If you're trying to do this in a script (or even `|` it to `less` or `grep`), the lines will get oddly wrapped because it assumes a default screen width. You need to do a bit of magic to get the "expected" formatting of one package per line (via [Allen Kistler](http://fedora.12.x6.nabble.com/yum-list-display-some-package-in-2-rows-tp2496921p2496962.html) via [bugzilla](https://bugzilla.redhat.com/show_bug.cgi?id=584525#c9)) - `yum list installed | tr "\n" "#" | sed -e 's/# / /g' | tr "#" "\n"` – bto Feb 28 '20 at 13:25
4

Based on and answer by Swoogan
On RedHat and CentOS one can do

sudo grep -ir PACKAGE_NAME /var/cache/yum/

The results should look something like

Binary file /var/cache/yum/REPOSITORY_NAME/primary.xml.gz.sqlite matches

Where repository_name is the repository where your package can be found, and it was probably installed from the first one in a list (see yum repolist)

iddqd
  • 193
  • 1
  • 8
4

If the package was installed recently, you can look in /var/cache/yum.

Within that directory, there is a directory for each repo, and in that a packages directory. So, you would do something like:

find /var/cache/yum -name [package-name]*

However, cache has to be enabled in your /etc/yum.conf file:

cachedir=/var/cache/yum
keepcache=1

Note that a yum clean [packages|all] will clear out the cache directory.

If the cache directory is empty, there is an alternative way. The information that is read by yum info [package] comes from /var/cache/yum/[repo]/primary.xml.gz

You can look through the file by entering:

gunzip -d -c /var/cache/yum/[repo]/primary.xml.gz | grep '<name>[package]'

However, on machines where yum info [package] does not display "From repo : ", as indicated by 'theotherreceive', it is because it is not in the file primary.xml, so there will be no way to retrieve that information. Therefore, if the package is in two or more primary.xml files, you will have to determine the repo priority on you system.

Swoogan
  • 2,007
  • 1
  • 13
  • 21
  • This solution maybe an option (I vote it), but I am looking for a definitive answer. – lg. Sep 04 '09 at 07:34
2

So I know this is a somewhat old question - but it comes up on the google search for what I was looking for.

There is also a method to get a unique list of repos used:

# repoquery -ai | grep 'Repository  : ' | sort | uniq

This will list the repositories that have had packages installed from.

2

None of the above commands worked for me. This is what I had to do.

yum provides "*compat-libstdc*"

A good reference is here.

https://access.redhat.com/sites/default/files/attachments/rh_yum_cheatsheet_1214_jcs_print-1.pdf

cokedude
  • 121
  • 2
1

Is that information captured anywhere? The package doesn't have that information, and yum doesn't care after it finds the package. You could probably piece it together by figuring out what repos have the package and then determine which one has priority.

Alex
  • 6,477
  • 1
  • 23
  • 32
  • This solution maybe an option (I vote it), but only for recent installed package, because I can change the repository and their priority. – lg. Sep 04 '09 at 07:31
1

Not a great solution, but I found that yum list available will show you where the most up to date version of each package is available, e.g.:

yum list available | grep gstreamer

PackageKit-gstreamer-plugin.x86_64 0.3.16-1.fc10          updates               

bluez-gstreamer.i386 4.30-2.fc10 updates
gstreamer.i386 0.10.21-2.fc10 fedora
gstreamer-devel.i386 0.10.21-2.fc10 fedora
gstreamer-devel.x86_64 0.10.21-2.fc10 fedora
gstreamer-plugins-bad-devel.i386 0.10.9-1.fc10 rpmfusion-free
gstreamer-plugins-bad-devel.x86_64 0.10.9-1.fc10 rpmfusion-free

So you could do a yum list available on your package, then compare your installed version using yum list installed, and have a good idea of which repo it came from if the versions match.

gareth_bowles
  • 8,867
  • 9
  • 33
  • 42
  • This is true only is the package is not yet installed. – lg. Sep 04 '09 at 07:20
  • While it doesn't answer the OPs question exactly, it was very helpful for me because it works in Centoss 5.5 with just yum and no other utils, and you can: 1. Uninstall the package then query to see where the repo is then reinstall, or 2. Query on a different machine without the package installed. – lreeder Dec 04 '14 at 04:09
1

You can add the verbose flag to "yum info":

yum info -v <package_name>

The installation repository will be under the "From repo" output.

smw
  • 11
  • 2
-1

The easiest way is this:

rpm -qa --qf '%{NAME} %{VENDOR}\n'

More tips and tricks are available here: http://wiki.centos.org/TipsAndTricks/YumAndRPM

Greg Dubicki
  • 1,191
  • 1
  • 14
  • 30
Bluesguy
  • 7
  • 1