RPM has five basic modes of operation (not including package building)
1. Installing – i
2. Upgrading – U
3. Freshening – F
4. Uninstalling – e
5. Querying – q
6. Verifying – V
7. Check signature – K
Installing
rpm –i
v – Verbose
h – The package archive is unpacked
–force – force
–test – install simulate
–nodeps – don’t check dependency
Upgrading
rpm –Uvh
–force
–replacepkgs
–replacefiles
–oldpackage
Freshening
rpm –Fvh
Unistalling
rpm –ev
–force
–nodeps
Querying
rpm –q[options]
a – query all installed packages
c – List only configuration files (-l)
f – Query package owning file
d – List only documents file (-l)
g – Query packages with the group of GROUP
p – Package file (to specify the package name
l – List
i – Display packages information
s – Display the states of files (normal, not installed, replaced)
R – Requires
–last – listing by install time such
–whatprovides
Verifying
rpm –V
a – all
p – Specify the package
f – Specify the file
Check the signature
rpm –Kv
Examples
1. How to install the rpm package
[root@linux Packages]# rpm -ivh firefox-3.6.24-3.el6_1.x86_64.rpm
warning: firefox-3.6.24-3.el6_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing… ########################################### [100%]
1:firefox ########################################### [100%]
2. How uninstall the rpm package
[root@linux yum.repos.d]# rpm -ev firefox
3. How to check the last installed rpm package with time and date
[root@linux Packages]# rpm -qa –last | head
firefox-3.6.24-3.el6_1 Sun 16 Sep 2012 07:48:07 PM IST
ftp-0.17-51.1.el6 Sat 15 Sep 2012 09:21:23 AM IST
ypserv-2.19-22.el6 Sat 15 Sep 2012 08:16:55 AM IST
tree-1.5.3-2.el6 Sat 15 Sep 2012 08:11:46 AM IST
words-3.0-17.el6 Fri 20 Jul 2012 03:02:11 AM IST
man-pages-3.22-17.el6 Fri 20 Jul 2012 03:02:11 AM IST
zd1211-firmware-1.4-4.el6 Fri 20 Jul 2012 03:02:06 AM IST
xorg-x11-drv-ati-firmware-6.14.2-7.el6 Fri 20 Jul 2012 03:02:06 AM IST
rt73usb-firmware-1.8-7.el6 Fri 20 Jul 2012 03:02:06 AM IST
rt61pci-firmware-1.2-7.el6 Fri 20 Jul 2012 03:02:06 AM IST
4. How to reinstall the package
[root@linux Packages]# rpm -Uvh firefox-3.6.24-3.el6_1.x86_64.rpm
warning: firefox-3.6.24-3.el6_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing… ########################################### [100%]
package firefox-3.6.24-3.el6_1.x86_64 is already installed
[root@linux Packages]# rpm -Uvh –replacepkgs firefox-3.6.24-3.el6_1.x86_64.rpm
warning: firefox-3.6.24-3.el6_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing… ########################################### [100%]
1:firefox ########################################### [100%]
5. Which rpm package does file belong to?
[root@linux Packages]# rpm -qf /etc/vsftpd/vsftpd.conf
vsftpd-2.2.2-6.el6_0.1.x86_64
6. Locate documentation of a package that owns file using rpm –qdf and rpm -qdp
[root@linux Packages]# rpm -qdp firefox-3.6.24-3.el6_1.x86_64.rpm
warning: firefox-3.6.24-3.el6_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
/usr/lib64/firefox-3.6/LICENSE
/usr/lib64/firefox-3.6/README.txt
/usr/share/man/man1/firefox.1.gz
[root@linux Packages]# rpm -qdf /usr/bin/createrepo
/usr/share/doc/createrepo-0.9.8/COPYING
/usr/share/doc/createrepo-0.9.8/ChangeLog
/usr/share/doc/createrepo-0.9.8/README
/usr/share/man/man1/mergerepo.1.gz
/usr/share/man/man1/modifyrepo.1.gz
/usr/share/man/man8/createrepo.8.gz
7. How to check the configuration files
[root@linux Packages]# rpm -Kv vsftpd-2.2.2-6.el6_0.1.x86_64.rpm
vsftpd-2.2.2-6.el6_0.1.x86_64.rpm:
Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Header SHA1 digest: OK (8005076799a57ab5c13045b5dd0c2aa890c8ac03)
V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
MD5 digest: OK (25e1511c9e217d9d345dd2fb5f92503d)
8. Information about installed RPM package using rpm –qi, rpm –qip, rpm –qfi
[root@linux ~]# rpm -qi vsftpd
Name : vsftpd Relocations: (not relocatable)
Version : 2.2.2 Vendor: Red Hat, Inc.
Release : 6.el6_0.1 Build Date: Fri 04 Mar 2011 03:35:10 PM IST
Install Date: Thu 19 Jul 2012 09:58:04 PM IST Build Host: hs20-bc2-3.build.redhat.com
Group : System Environment/Daemons Source RPM: vsftpd-2.2.2-6.el6_0.1.src.rpm
Size : 338480 License: GPLv2 with exceptions
Signature : RSA/8, Wed 09 Mar 2011 07:39:28 PM IST, Key ID 199e2f91fd431d51
Packager : Red Hat, Inc.
URL : http://vsftpd.beasts.org/
Summary : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
[root@linux ~]# cd /var/ftp/pub/rhel6.2/Packages/
[root@linux Packages]# rpm -qip vsftpd-2.2.2-6.el6_0.1.x86_64.rpm
warning: vsftpd-2.2.2-6.el6_0.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Name : vsftpd Relocations: (not relocatable)
Version : 2.2.2 Vendor: Red Hat, Inc.
Release : 6.el6_0.1 Build Date: Fri 04 Mar 2011 03:35:10 PM IST
Install Date: (not installed) Build Host: hs20-bc2-3.build.redhat.com
Group : System Environment/Daemons Source RPM: vsftpd-2.2.2-6.el6_0.1.src.rpm
Size : 338480 License: GPLv2 with exceptions
Signature : RSA/8, Wed 09 Mar 2011 07:39:28 PM IST, Key ID 199e2f91fd431d51
Packager : Red Hat, Inc.
URL : http://vsftpd.beasts.org/
Summary : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
9. Verify a particular RPM package using rpm –Vp
[root@linux Packages]# rpm -Vp firefox-3.6.24-3.el6_1.x86_64.rpm
warning: firefox-3.6.24-3.el6_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
10. How to check the signature
[root@linux Packages]# rpm -Kv vsftpd-2.2.2-6.el6_0.1.x86_64.rpm
vsftpd-2.2.2-6.el6_0.1.x86_64.rpm:
Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Header SHA1 digest: OK (8005076799a57ab5c13045b5dd0c2aa890c8ac03)
V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
MD5 digest: OK (25e1511c9e217d9d345dd2fb5f92503d)
11. How to check the dependency rpm
[root@linux Packages]# rpm -qRp createrepo-0.9.8-4.el6.noarch.rpm
warning: createrepo-0.9.8-4.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
/bin/sh
/usr/bin/env
/usr/bin/python
deltarpm
libxml2-python
python >= 2.1
python(abi) = 2.6
python-deltarpm
rpm >= 4.1.1
rpm-python
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
yum >= 3.2.23-10
yum-metadata-parser
rpmlib(PayloadIsXz) <= 5.2-1
Review Questions
1. What two commands are used for package management?
2. What are the three modes in which the rpm command can operate?
3. What option would you use to query an installed package using the rpm
command?
4. How would you install a group of packages all at a single time?
5. What options with the yum command would you use to remove a package?
6. Where are Yum repository config files located?
7. What command can you use to create your own repositories?
8. What command is used to create an RPM package?
9. What are the five required directories when building RPMS?
10. If a package is built on an RHEL6 system and deployed to a custom RHEL5
repository, are RHEL5 systems able to use it?
Answers to Review Questions
1. The yum and rpm commands are used for package management.
2. The rpm command can operate in install, query, or verify modes.
3. You can use the -q option to query an installed package. Combining grep and
the -qa options, you can search among all installed packages on the system.
4. Use the yum groupinstall command to install multiple packages in a single
group at once.
5. You can use the remove or erase options with yum to remove a package.
6. Yum repository config files (.repo files) are located in the /etc/yum.repos.d directory.
You can also make direct entries into the main /etc/yum.conf file.
7. createrepo
8. rpmbuild
9. The five directories are BUILD, RPMS, SOURCES, SPECS, and SRPMS.
10. No. Red Hat Enterprise Linux 6 uses a different key to sign its packages.