Table of Content

Weight: 3

Description: Candidates should be able to perform package management using RPM and YUM tools.

Key Knowledge Areas:

  • Install, re-install, upgrade and remove packages using RPM and YUM
  • Obtain information on RPM packages such as version, status, dependencies, integrity and signatures
  • Determine what files a package provides, as well as find which package a specific file comes from

Terms and Utilities:

rpm
rpm2cpio
/etc/yum.conf
/etc/yum.repos.d/
yum
yumdownloader

rpm

rpm -i pkg
rpm -e --test pkg # dry-run to remove , similar like apt-get remove -s pkg

rpm -Uvh pkg.rpm
rpm -Uvh *.rpm url

rpm -ql lsof
rpm -qi lsof
rpm -qR lsof  # query 
rpm -qa |sort |more  all sorted pkg 
rpm -qal|wc -l # list of files
rpm -aqd |wc -l # doc files
rpm -qa |grep -i grep 

rpm -qf $(which lsof) # # query pkg name owning file
rpm -qif pkg # query info of pkg owning file
rpm -qlf file  # query file list of pkg owning file

rpm -qip pkg.rpm  # query info of pkg file
rpm -qlp pkg.rpm  # query file list of pkg file
rpm -qp pkg.rpm   # query pkg name

rpm -q --whatprovides lsof
lsof-4.87-4.el7.x86_64

rpm -i pkg.rpm --nodeps
rpm -i pkg.rpm --force

rpmbuild --rebuild pkg.src.rpm  # rebuild from source pkg

rpm -q pkg
rpm --checksig pkg.rpm  #  check sign
rpm -Fvh pkg.rpm # upgrade if already installed

rpm config

/usr/lib/rpm/rpmrc # don't edit
/etc/rpmrc # global setting
~/.rpmrc # user base setting

[root@dclab-centos7 rpm]# uname -p
x86_64

[root@dclab-centos7 rpm]# less /usr/lib/rpm/rpmrc|grep x86_64
optflags: x86_64 -O2 -g
archcolor: x86_64 2
arch_canon:     x86_64: x86_64  1
buildarchtranslate: x86_64: x86_64
buildarchtranslate: amd64: x86_64
buildarchtranslate: ia32e: x86_64
arch_compat: x86_64: amd64 em64t athlon noarch
arch_compat: amd64: x86_64 em64t athlon noarch
arch_compat: ia32e: x86_64 em64t athlon noarch
buildarch_compat: x86_64: noarch
buildarch_compat: amd64: x86_64
buildarch_compat: ia32e: x86_64

yum

/etc/yum.conf
/var/log/yum.log
/etc/yum.repos.d  # yum repo, similar as /etc/apt/sources.list

yum update "gr*"

yum list pkg 
yum info pkg
yum search pkg

check pkg dependency 
yum deplist $(rpm -q lsof)

yum deplist $(rpm -q lsof)|awk '/provider:/ {print $2}' |sort |uniq

yum whatprovides lsof

yumdownloader

yumdownloader --resolve lsof  # download rpm pkg and dependency  
lsof-4.87-4.el7.x86_64.rpm

rpm -vK lsof-4.87-4.el7.x86_64.rpm   # check integrity of pkg 

unpack rpm package

mkdir lsof
cd lsof
rpm2cpio ../lsof-4.87-4.el7.x86_64.rpm |cpio -idv

Quiz questions

1. Which command will list the files that will be installed from the package bogus10.1.rpm?
2. Which commands will enable you to identify the author of lilo given the file /sbin/lilo was installed as part of an rpm package?
3. Which flag for rpm -q specifies that you wish to query an installed package by specifying a file installed by that package?
4. What is the configuration file for rpm?
5. What does the rpm database of installed packages contain?
6. How can grep be used together with rpm?
7. How does one check that an rpm file has not been tampered with since it was packaged?

Answers to quiz questions

1. rpm - qlp bogus10.1.rpm
2. rpm -qif /sbin/lilo
3. -f
4. /etc/rpmrc
5. Information about each package, and about each installed file.
6. rpm -qa| grep package 
rpm -ql package | grep bin 
7. rpm --checksig package.rpm