How to know from which yum repository a package has been installed?

298,264

Solution 1

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.

Solution 2

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.

Solution 3

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'

Solution 4

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.

Solution 5

rpm -qi packagename

Will tell you the vendor and packager

Share:
298,264

Related videos on Youtube

lg.
Author by

lg.

Updated on September 17, 2022

Comments

  • lg.
    lg. over 1 year

    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".

    • Carlos Abalde
      Carlos Abalde over 14 years
      Great question! I installed yum-utils and tried one it's utils called repoquery, but no luck.
    • warren
      warren over 14 years
    • Trevor Boyd Smith
      Trevor Boyd Smith over 7 years
      @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
      Trevor Boyd Smith over 7 years
      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.
    • warren
      warren over 7 years
      @TrevorBoydSmith - 7 years ago, it was close. Today, it's still similar. Never said it was the same. Just that it was related.
  • lg.
    lg. over 14 years
    I'm using yum 3.2.19 on CentOs 5.3 and "From repo" row doesn't exist.
  • Alex
    Alex over 14 years
    Yep...I was testing it on 3.2.21, which doesn't have that info anywhere. When I did it on my box that has 3.2.23, it worked.
  • lg.
    lg. over 14 years
    This is true only is the package is not yet installed.
  • lg.
    lg. over 14 years
    This solution maybe an option (I vote it), but only for recent installed package, because I can change the repository and their priority.
  • lg.
    lg. over 14 years
    This solution maybe an option (I vote it), but I am looking for a definitive answer.
  • lg.
    lg. over 14 years
    Now this is the best solution, but not applicable for RHEL/Centos 5.3. I accept this solution, but I ready to choose another answer if will be applicable also for RHEL/Centos 5.3.
  • wolfand11
    wolfand11 over 13 years
    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.
  • wolfand11
    wolfand11 over 13 years
    This is a no-go in CentOS 5.5 either.
  • lg.
    lg. over 13 years
    In this way (adding a pipe whith grep -i package name) I discover the vendor, but not the repository.
  • lg.
    lg. over 12 years
    It works also on Fedora 14
  • pixelbeat
    pixelbeat over 12 years
    works on RHEL 6.2
  • Matteo
    Matteo almost 12 years
    The vendor has (almost) nothing to do with the repository.
  • baseem beg
    baseem beg over 11 years
    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.
  • Admin
    Admin over 11 years
    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.
  • sepehr
    sepehr about 11 years
    "From rep" is not available even in centos 5.8
  • Silver Moon
    Silver Moon almost 11 years
    the yum command will just show "Repo : installed" which means nothing
  • Xiong Chiamiov
    Xiong Chiamiov over 10 years
    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.
  • lreeder
    lreeder over 9 years
    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.
  • Greg Dubicki
    Greg Dubicki over 8 years
    +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!
  • Michael Hampton
    Michael Hampton over 8 years
    @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.
  • Mark Edington
    Mark Edington over 7 years
    This seems to be the only solution that does not require installing yum-utils.
  • Mark Edington
    Mark Edington over 7 years
    From an answer below, when passed the -v (verbose) flag, yum info has "From repo: " entry.
  • frogstarr78
    frogstarr78 about 5 years
    This only lists "installed" for me.
  • Warwick
    Warwick over 4 years
    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!
  • Steve Bonds
    Steve Bonds over 4 years
    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
  • bto
    bto about 4 years
    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 via bugzilla) - yum list installed | tr "\n" "#" | sed -e 's/# / /g' | tr "#" "\n"
  • M_dk
    M_dk almost 4 years
    This answer is incorrect, as stated above it shows from where a package is available, not where it was installed from as asked.
  • pevik
    pevik over 2 years
    NOTE: provides subcommand is supported also by dnf.