Reputation: 11
How can I efficiently list installed and available packages on Cent OS?
I have already tried yum list
installed, which is supposed to output the list of all installed while rpm -qa
produces a different result in size.
Which one should I trust? Or am I omitting something?
Upvotes: 1
Views: 1136
Reputation: 4561
My understanding is: rpm -qa
is better to know what is installed (RPM packages, right! ). Whereas yum
is better to know what could be installed and find required dependencies. It is usually fine to use yum
for both purposes.
I tested on a CentOS 7 system. They have almost identical list, except that rpm also reports some gpg-pubkey
pseudo packages (try rpm -qa gpg-pubkey\*
).
If you want to compare the lists on your system, first get the rpm
's list:
$ rpm -q -a --qf '%{NAME}\t%{ARCH}\t%{VERSION}\t%{RELEASE}\n' | sort > /tmp/rpm-qa.lst
Then extract YUM's list (using repoquery
which is part of package yum-utils
:
$ repoquery -q -a --installed --qf '%{NAME}\t%{ARCH}\t%{VERSION}\t%{RELEASE}' | sort > /tmp/repo-qa.lst
Then compare:
$ diff -u0 /tmp/rpm-qa.lst /tmp/repo-qa.lst
--- /tmp/rpm-qa.lst 2015-03-08 16:07:38.297325253 +0100
+++ /tmp/repo-qa.lst 2015-03-08 16:07:43.281438369 +0100
@@ -143,1 +142,0 @@
-gpg-pubkey (none) 352c64e5 52ae6884
(See also question https://unix.stackexchange.com/q/190203/16640)
Upvotes: 2
Reputation: 31
Both commands works in the same way only difference is 'yum list installed' output maybe bigger than 'rpm -qa' because yum will show package dependencies also in its output.
While installing a package using rpm, we need to manually install the dependencies whereas yum will do that automatically. So in this case if you want to list the packages only use, 'rpm -qa' or if you need to list all the packages and dependencies associated with it use 'yum list installed'
Upvotes: 0