list all installed packages |
rpm -qa |
show information about specific package |
rpm -qi packagename |
list specific package if it is installed |
rpm -q packagename |
install a package with verbose output |
rpm -ivh package.rpm |
uninstall current version |
rpm -e packagename |
list dependencies |
rpm -qRp package.rpm
rpm -qR packagename
Apply this in a script to scan all installed packages and print
packages that depend on a specific package
e.g. check which installed package depends on libssh2
dp=libssh2
for pkg in `rpm -qa | sort | uniq`
do
if [ "-`rpm -qR $pkg | grep $dp`-" != "--" ]; then
echo $pkg depends on $dp
fi
done
libcurl-7.29.0-57.el7_8.1.x86_64 depends on libssh2
mc-4.8.7-11.el7.x86_64 depends on libssh2
qemu-img-1.5.3-173.el7_8.3.x86_64 depends on libssh2
qemu-kvm-1.5.3-173.el7_8.3.x86_64 depends on libssh2
|
list files in package |
rpm -qlp package.rpm
rpm -ql packagename
|
Look for dependency on a package if it was removed
|
rpm -e --test packagename
-e ==> remove
--test ==> test only
It will give a warning
|
list package that provides a file |
rpm -qf file-full-path
e.g.
rpm -qf /bin/python
python-2.7.5-88.el7.x86_64
alternatively.
rpm -q --whatprovides /usr/bin/python
python-2.7.5-88.el7.x86_64
|
TEST package installation or removal |
rpm -ivh - - test packagename
rpm -ev --test packagename |
install all rpms that depend on each other.
|
put all .rpm in one directory
rpm -ivh *.rpm
|
check last install date of a package |
rpm --last -q packagename
e.g.
rpm --last -q sendmail
|
list packages that requires a specific package
(i.e. depends on) |
e.g.
[root@rhel7client1 ~]# rpm -q --whatrequires glibc
glibc-common-2.17-307.el7.1.x86_64
libstdc++-4.8.5-39.el7.x86_64
pam-1.1.8-23.el7.x86_64
glibc-headers-2.17-307.el7.1.x86_64
glibc-devel-2.17-307.el7.1.x86_64
lockdev-1.0.4-0.13.20111007git.el7.x86_64
postgresql-libs-9.2.24-4.el7_8.x86_64
ppp-2.4.5-34.el7_7.x86_64
Thus the reverse will show that ppp requires glibc :
[root@rhel7client1 ~]# rpm -qR ppp | grep glibc
glibc >= 2.0.6
|
List packages that are found in a particular yum repository |
yum repository-packages repo-name list
## For example we have a repo named remi-php3
## we want to list ALL the packages found in this repo
yum repository-packages remi-php73 list
|
Display query output in specific formats with format strings |
## display possible query tags to use in the query format
[root@localhost]# rpm --querytags
ARCH
ARCHIVESIZE
BASENAMES
BUGURL
BUILDARCHS
BUILDHOST
BUILDTIME
C
CHANGELOGNAME
CHANGELOGTEXT
CHANGELOGTIME
CLASSDICT
COLLECTIONS
CONFLICTFLAGS
CONFLICTNAME
CONFLICTNEVRS
CONFLICTS
CONFLICTVERSION
COOKIE
DBINSTANCE
DEPENDSDICT
DESCRIPTION
DIRINDEXES
DIRNAMES
DISTRIBUTION
DISTTAG
DISTURL
DSAHEADER
E
ENHANCEFLAGS
ENHANCENAME
ENHANCES
ENHANCEVERSION
EPOCH
EPOCHNUM
EVR
EXCLUDEARCH
EXCLUDEOS
EXCLUSIVEARCH
EXCLUSIVEOS
FILECAPS
FILECLASS
FILECOLORS
FILECONTEXTS
FILEDEPENDSN
FILEDEPENDSX
FILEDEVICES
FILEDIGESTALGO
FILEDIGESTS
FILEFLAGS
FILEGROUPNAME
FILEINODES
FILELANGS
FILELINKTOS
FILEMD5S
FILEMODES
FILEMTIMES
FILENAMES
FILENLINKS
FILEPROVIDE
FILERDEVS
FILEREQUIRE
FILESIZES
FILESTATES
FILEUSERNAME
FILEVERIFYFLAGS
FSCONTEXTS
GIF
GROUP
HDRID
HEADERCOLOR
HEADERI18NTABLE
HEADERIMAGE
HEADERIMMUTABLE
HEADERREGIONS
HEADERSIGNATURES
ICON
INSTALLCOLOR
INSTALLTID
INSTALLTIME
INSTFILENAMES
INSTPREFIXES
LICENSE
LONGARCHIVESIZE
LONGFILESIZES
LONGSIGSIZE
LONGSIZE
N
NAME
NEVR
NEVRA
NOPATCH
NOSOURCE
NVR
NVRA
O
OBSOLETEFLAGS
OBSOLETENAME
OBSOLETENEVRS
OBSOLETES
OBSOLETEVERSION
OLDFILENAMES
OPTFLAGS
ORDERFLAGS
ORDERNAME
ORDERVERSION
ORIGBASENAMES
ORIGDIRINDEXES
ORIGDIRNAMES
ORIGFILENAMES
OS
P
PACKAGER
PATCH
PATCHESFLAGS
PATCHESNAME
PATCHESVERSION
PAYLOADCOMPRESSOR
PAYLOADFLAGS
PAYLOADFORMAT
PKGID
PLATFORM
POLICIES
POLICYFLAGS
POLICYNAMES
POLICYTYPES
POLICYTYPESINDEXES
POSTIN
POSTINFLAGS
POSTINPROG
POSTTRANS
POSTTRANSFLAGS
POSTTRANSPROG
POSTUN
POSTUNFLAGS
POSTUNPROG
PREFIXES
PREIN
PREINFLAGS
PREINPROG
PRETRANS
PRETRANSFLAGS
PRETRANSPROG
PREUN
PREUNFLAGS
PREUNPROG
PROVIDEFLAGS
PROVIDENAME
PROVIDENEVRS
PROVIDES
PROVIDEVERSION
PUBKEYS
R
RECOMMENDFLAGS
RECOMMENDNAME
RECOMMENDS
RECOMMENDVERSION
RECONTEXTS
RELEASE
REMOVETID
REQUIREFLAGS
REQUIRENAME
REQUIRENEVRS
REQUIRES
REQUIREVERSION
RPMVERSION
RSAHEADER
SHA1HEADER
SIGGPG
SIGMD5
SIGPGP
SIGSIZE
SIZE
SOURCE
SOURCEPACKAGE
SOURCEPKGID
SOURCERPM
SUGGESTFLAGS
SUGGESTNAME
SUGGESTS
SUGGESTVERSION
SUMMARY
SUPPLEMENTFLAGS
SUPPLEMENTNAME
SUPPLEMENTS
SUPPLEMENTVERSION
TRIGGERCONDS
TRIGGERFLAGS
TRIGGERINDEX
TRIGGERNAME
TRIGGERSCRIPTFLAGS
TRIGGERSCRIPTPROG
TRIGGERSCRIPTS
TRIGGERTYPE
TRIGGERVERSION
URL
V
VCS
VENDOR
VERBOSE
VERIFYSCRIPT
VERIFYSCRIPTFLAGS
VERIFYSCRIPTPROG
VERSION
XP
## display NAME, VERSION, INSTALLTIME
# rpm -qa --qf "%-20{NAME} %-12{VERSION} %-30{INSTALLTIME:day}\n" | head -5
dos2unix 6.0.3 Fri Oct 02 2020
cups-libs 1.6.3 Wed May 27 2020
ansible-tower-ui 3.7.3 Fri Oct 16 2020
libXinerama 1.1.3 Wed May 27 2020
memcached 1.4.15 Fri Mar 13 2020
|
How to verify packages |
## To verify all packages
rpm -Va
## To verify specific package
rpm -Vp packagename
## What are the meaning of the attribute marker characters from rpm -V command
the 9 character attribute :-
S file Size differes
M Mode differs
5 digest (MD5 sum) differs
D Device major/minor number mismatch
L readLink path mismatch
U User ownership differs
G Group ownership differs
T mTime differs
P caPabilities differ
the 1 character marker :-
c %config i.e. config file
d %doc i.e. documentation file
g %ghost file (i.e. not part of package payload)
l %license file
r %readme file
|