Powered By GitBook
102.5. Use RPM and YUM package management

102.5 Use RPM and YUM package management

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
In this lesson we learn how to work with packages in RedHat Distributions. If you are not familiar with Package and package Manager concepts in linux please study first part of previous lesson.

rpm

RPM (Red Hat Package Manager) is a powerful Package Manager, which can be used to build, install, query, verify, update, and erase individual software packages.
A package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package.
Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages. RPM is the only way to install packages under Linux systems, if you’ve installed packages using source code, then rpm won’t manage it.
RPM deals with .rpm files, which contains the actual information about the packages such as: what it is, from where it comes, dependencies info, version info etc.

Where to find RPM packages

list of rpm sites, where we can find and download all RPM packages:
RPM keeps the information of all the installed packages under /var/lib/rpm database.
1
[[email protected] ~]# ls -l /var/lib/rpm
2
total 86688
3
-rw-r--r--. 1 root root 3821568 Dec 5 10:02 Basenames
4
-rw-r--r--. 1 root root 16384 Dec 5 10:02 Conflictname
5
-rw-r--r-- 1 root root 311296 Dec 8 11:26 __db.001
6
-rw-r--r-- 1 root root 90112 Dec 8 11:26 __db.002
7
-rw-r--r-- 1 root root 1318912 Dec 8 11:26 __db.003
8
-rw-r--r--. 1 root root 1134592 Dec 5 10:02 Dirnames
9
-rw-r--r--. 1 root root 32768 Dec 5 10:02 Group
10
-rw-r--r--. 1 root root 20480 Dec 5 10:02 Installtid
11
-rw-r--r--. 1 root root 69632 Dec 5 10:02 Name
12
-rw-r--r--. 1 root root 32768 Dec 5 10:02 Obsoletename
13
-rw-r--r--. 1 root root 78909440 Dec 5 10:02 Packages
14
-rw-r--r--. 1 root root 2404352 Dec 5 10:02 Providename
15
-rw-r--r--. 1 root root 520192 Dec 5 10:02 Requirename
16
-rw-r--r--. 1 root root 131072 Dec 5 10:02 Sha1header
17
-rw-r--r--. 1 root root 73728 Dec 5 10:02 Sigmd5
18
-rw-r--r--. 1 root root 8192 Dec 5 10:02 Triggername
Copied!
They are all binary files, try cat Basenames to see.
There are five basic modes for RPM command:
    Install : It is used to install any RPM package.
    Remove : It is used to erase, remove or un-install any RPM package.
    Upgrade : It is used to update the existing RPM package.
    Verify : It is used to verify an RPM packages.
    Query : It is used query any RPM package.

Install an RPM Package

-i is used for installing an rpm software package
1
[[email protected] ~]# rpm -ivh zip-3.0-11.el7.x86_64.rpm
2
Preparing... ################################# [100%]
3
Updating / installing...
4
1:zip-3.0-11.el7 ################################# [100%]
Copied!
-v verbose for a nicer display ,-h print hash marks as the package archive is unpacked.

Check an Installed RPM Package

-q option query a package:
1
[[email protected] ~]# rpm -q zip
2
zip-3.0-11.el7.x86_64
Copied!

List all files of an installed RPM package

Use -ql (query list) with rpm command:
1
[[email protected] ~]# rpm -ql zip
2
/usr/bin/zip
3
/usr/bin/zipcloak
4
/usr/bin/zipnote
5
/usr/bin/zipsplit
6
/usr/share/doc/zip-3.0
7
/usr/share/doc/zip-3.0/CHANGES
8
/usr/share/doc/zip-3.0/LICENSE
9
/usr/share/doc/zip-3.0/README
10
/usr/share/doc/zip-3.0/README.CR
11
/usr/share/doc/zip-3.0/TODO
12
/usr/share/doc/zip-3.0/WHATSNEW
13
/usr/share/doc/zip-3.0/WHERE
14
/usr/share/doc/zip-3.0/algorith.txt
15
/usr/share/man/man1/zip.1.gz
16
/usr/share/man/man1/zipcloak.1.gz
17
/usr/share/man/man1/zipnote.1.gz
18
/usr/share/man/man1/zipsplit.1.gz
Copied!

Query a file that belongs which RPM Package

-qf (query file) option help us to find out which package belongs to a file.
1
[[email protected] ~]# rpm -qf /usr/bin/zipsplit
2
zip-3.0-11.el7.x86_64
Copied!

Query a Information of Installed RPM Package

-qi (query info) option will print the available information of the installed package.
1
[[email protected] ~]# rpm -qi zip
2
Name : zip
3
Version : 3.0
4
Release : 11.el7
5
Architecture: x86_64
6
Install Date: Mon 03 Dec 2018 06:05:54 AM EST
7
Group : Applications/Archiving
8
Size : 815173
9
License : BSD
10
Signature : RSA/SHA256, Sun 20 Nov 2016 04:04:58 PM EST, Key ID 24c6a8a7f4a80eb5
11
Source RPM : zip-3.0-11.el7.src.rpm
12
Build Date : Sat 05 Nov 2016 12:49:55 PM EDT
13
Build Host : worker1.bsys.centos.org
14
Relocations : (not relocatable)
15
Packager : CentOS BuildSystem <http://bugs.centos.org>
16
Vendor : CentOS
17
URL : http://www.info-zip.org/Zip.html
18
Summary : A file compression and packaging utility compatible with PKZIP
19
Description :
20
The zip program is a compression and file packaging utility. Zip is
21
analogous to a combination of the UNIX tar and compress commands and
22
is compatible with PKZIP (a compression and file packaging utility for
23
MS-DOS systems).
24
25
Install the zip package if you need to compress files using the zip
26
program.
Copied!

Get the Information of RPM Package Before Installing

-qip (query info package) will print the information of a package , as the package has not been installed there is nothing to read by rpm in its data base, so we need to give full name of the package and it would provide required information directly from rpm package:
1
[[email protected] ~]# rpm -qip htop-2.2.0-1.el7.x86_64.rpm
2
Name : htop
3
Version : 2.2.0
4
Release : 1.el7
5
Architecture: x86_64
6
Install Date: (not installed)
7
Group : Unspecified
8
Size : 222746
9
License : GPLv2+
10
Signature : RSA/SHA256, Wed 30 May 2018 06:30:22 PM EDT, Key ID 6a2faea2352c64e5
11
Source RPM : htop-2.2.0-1.el7.src.rpm
12
Build Date : Wed 30 May 2018 06:26:05 PM EDT
13
Build Host : buildvm-31.phx2.fedoraproject.org
14
Relocations : (not relocatable)
15
Packager : Fedora Project
16
Vendor : Fedora Project
17
URL : http://hisham.hm/htop/
18
Bug URL : https://bugz.fedoraproject.org/htop
19
Summary : Interactive process viewer
20
Description :
21
htop is an interactive text-mode process viewer for Linux, similar to
22
top(1).
Copied!
-p is used to query information from rpm package. We can omit -p and use Package name instead rpm -qi htop .

check dependencies of RPM Package before Installing

Use -qpR options to do a dependency check before installing or upgrading a package
1
[[email protected] ~]# rpm -qpR htop-2.2.0-1.el7.x86_64.rpm
2
libc.so.6()(64bit)
3
libc.so.6(GLIBC_2.14)(64bit)
4
libc.so.6(GLIBC_2.15)(64bit)
5
libc.so.6(GLIBC_2.2.5)(64bit)
6
libc.so.6(GLIBC_2.3)(64bit)
7
libc.so.6(GLIBC_2.3.4)(64bit)
8
libc.so.6(GLIBC_2.4)(64bit)
9
libc.so.6(GLIBC_2.8)(64bit)
10
libgcc_s.so.1()(64bit)
11
libgcc_s.so.1(GCC_3.0)(64bit)
12
libgcc_s.so.1(GCC_3.3.1)(64bit)
13
libm.so.6()(64bit)
14
libm.so.6(GLIBC_2.2.5)(64bit)
15
libncursesw.so.5()(64bit)
16
libtinfo.so.5()(64bit)
17
rpmlib(CompressedFileNames) <= 3.0.4-1
18
rpmlib(FileDigests) <= 4.6.0-1
19
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
20
rtld(GNU_HASH)
21
rpmlib(PayloadIsXz) <= 5.2-1
Copied!
-R List capabilities on which this package depends. we can easily use rpm -qR PackageName to query an installed package.
Query configuration file of Installed RPM Packae
-qc (query configuration file) will query an installed package for its configuration files, if it has any:
1
[[email protected] ~]# rpm -qc vsftpd
2
/etc/logrotate.d/vsftpd
3
/etc/pam.d/vsftpd
4
/etc/vsftpd/ftpusers
5
/etc/vsftpd/user_list
6
/etc/vsftpd/vsftpd.conf
Copied!
If the package is not installed use -qpc instead to query a rpm package.

Query documentation of Installed RPM Package

-qdf(query document file) gives a list of available documentation of an installed package:
1
[[email protected] ~]# which zip
2
/bin/zip
3
[[email protected] ~]# rpm -qdf /bin/zip
4
/usr/share/doc/zip-3.0/CHANGES
5
/usr/share/doc/zip-3.0/LICENSE
6
/usr/share/doc/zip-3.0/README
7
/usr/share/doc/zip-3.0/README.CR
8
/usr/share/doc/zip-3.0/TODO
9
/usr/share/doc/zip-3.0/WHATSNEW
10
/usr/share/doc/zip-3.0/WHERE
11
/usr/share/doc/zip-3.0/algorith.txt
12
/usr/share/man/man1/zip.1.gz
13
/usr/share/man/man1/zipcloak.1.gz
14
/usr/share/man/man1/zipnote.1.gz
15
/usr/share/man/man1/zipsplit.1.gz
Copied!

Verify a installed Package

-V(verify) verifies a package:
1
[[email protected] ~]# rpm -V telnet
Copied!
No news is good news.When verifying a package, RPM produces output only if there is a verification failure. When a file fails verification, the format of the output is a bit cryptic, but it packs all the information you need into one line per file. Here is the format: SM5DLUGT c <file> . As an example:
1
[[email protected] ~]# rpm -V vsftpd
2
S.5....T. c /etc/vsftpd/ftpusers
Copied!
Where:
    S is the file size.
    M is the file's mode.
    5 is the MD5 checksum of the file.
    D is the file's major and minor numbers.
    L is the file's symbolic link contents.
    U is owner of the file.
    G is the file's group.
    T is the modification time of the file.
    c appears only if the file is a configuration file. This is handy for quickly identifying config files, as they are very likely to change, and therefore, very unlikely to verify successfully.
    <file> is the file that failed verification. The complete path is listed to make it easy to find.

Verify all RPM Packages

Use -Va(Verify all) to verify all the installed rpm packages.
1
[[email protected] ~]# rpm -Va
2
S.5....T. c /etc/cgrules.conf
3
missing /var/run/pluto
4
....L.... c /etc/pam.d/fingerprint-auth
5
....L.... c /etc/pam.d/password-auth
6
....L.... c /etc/pam.d/postlogin
7
....L.... c /etc/pam.d/smartcard-auth
8
....L.... c /etc/pam.d/system-auth
9
missing /var/run/gluster
10
S.5....T. c /etc/yum/pluginconf.d/langpacks.conf
11
S.5....T. c /etc/plymouth/plymouthd.conf
12
S.5....T. c /etc/cups/cups-browsed.conf
13
.M....G.. /var/log/gdm
14
missing /var/run/pulse
15
S.5....T. c /etc/sysconfig/authconfig
16
missing /var/run/wpa_supplicant
Copied!
use rpm -Vac to just verify configuration files.There would be some common system script which are routinely changed.

Verify a RPM Package

Verifying a package compares information of installed files of the package against the rpm database.
The-Vp (verify package) is used to verify a package.
1
[[email protected] ~]# rpm -Vp zip-3.0-11.el7.x86_64.rpm
2
[[email protected] ~]# rpm -Vp htop-2.2.0-1.el7.x86_64.rpm
3
missing /usr/bin/htop
4
missing /usr/share/applications/htop.desktop
5
missing /usr/share/doc/htop-2.2.0
6
missing d /usr/share/doc/htop-2.2.0/AUTHORS
7
missing d /usr/share/doc/htop-2.2.0/ChangeLog
8
missing d /usr/share/doc/htop-2.2.0/README
9
missing /usr/share/licenses/htop-2.2.0
10
missing l /usr/share/licenses/htop-2.2.0/COPYING
11
missing d /usr/share/man/man1/htop.1.gz
12
missing /usr/share/pixmaps/htop.png
Copied!

List all Installed RPM Packages

-qa (query all) option, will list all the installed rpm packages.
1
[[email protected] ~]# rpm -qa
2
NetworkManager-team-1.8.0-9.el7.x86_64
3
cdparanoia-libs-10.2-17.el7.x86_64
4
gtkmm30-3.22.0-1.el7.x86_64
5
python-configshell-1.1.fb23-3.el7.noarch
6
khmeros-base-fonts-5.0-17.el7.noarch
7
liberation-fonts-common-1.07.2-15.el7.noarch
8
kexec-tools-2.0.14-17.el7.x86_64
9
iptables-1.4.21-18.0.1.el7.centos.x86_64
10
gnome-dictionary-libs-3.20.0-1.el7.x86_64
11
gd-2.0.35-26.el7.x86_64
12
setserial-2.17-33.el7.x86_64
13
mozilla-filesystem-1.9-11.el7.x86_64
14
...
15
<the output has been truncated>
Copied!
use --last option to list recently installed RPM Packages.

Upgrade a RPM Package

-U upgrades or installs the package currently installed to a newer version. This is the same as install, except all other version(s) of the package are removed after the new package is installed.
1
[[email protected] ~]# rpm -Uvh telnet-0.17-64.el7.x86_64.rpm
2
Preparing... ################################# [100%]
3
Updating / installing...
4
1:telnet-1:0.17-64.el7 ################################# [100%]
Copied!
One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.(via rpm --oldpackage switch or using yum downgrade )
rpm -ivh vs rpm -Uvh
rpm -ivh just installs a package and if the package is already installed it won't do any things, but rpm -Uvh installs it, even if it exists.
Also rpm -ivh might cause having multiple version of a package at the same time but by using rpm -Uvh we are sure that we just have the latest version.
-F will upgrade packages, but only ones for which an earlier version is installed.( means upgrade if installed other wise do noting)

Remove a RPM Package

-e (erase) option is used to remove package (add v or vv for more verbosity):
1
[[email protected] ~]# rpm -evv zip
2
D: loading keyring from pubkeys in /var/lib/rpm/pubkeys/*.key
3
D: couldn't find any keys in /var/lib/rpm/pubkeys/*.key
4
D: loading keyring from rpmdb
5
D: opening db environment /var/lib/rpm cdb:0x401
6
D: opening db index /var/lib/rpm/Packages 0x400 mode=0x0
7
D: locked db index /var/lib/rpm/Packages
8
D: opening db index /var/lib/rpm/Name 0x400 mode=0x0
9
D: read h# 1319 Header SHA1 digest: OK (489efff35e604042709daf46fb78611fe90a75aa)
10
D: added key gpg-pubkey-f4a80eb5-53a7ff4b to keyring
11
D: read h# 1337 Header SHA1 digest: OK (dd737a402556b7653c2bc971f343532046e26384)
12
D: added key gpg-pubkey-352c64e5-52ae6884 to keyring
13
D: Using legacy gpg-pubkey(s) from rpmdb
14
D: read h# 1341 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: OK
15
D: opening db index /var/lib/rpm/Conflictname 0x400 mode=0x0
16
D: ========== --- zip-3.0-11.el7 x86_64/linux 0x2
17
D: opening db index /var/lib/rpm/Requirename 0x400 mode=0x0
18
D: ========== recording tsort relations
19
D: ========== tsorting packages (order, #predecessors, #succesors, depth)
20
D: 0 0 0 1 -zip-3.0-11.el7.x86_64
21
D: erasing packages
22
D: Selinux disabled.
23
D: closed db index /var/lib/rpm/Conflictname
24
D: closed db index /var/lib/rpm/Requirename
25
D: closed db index /var/lib/rpm/Name
26
D: closed db index /var/lib/rpm/Packages
27
D: closed db environment /var/lib/rpm
28
D: opening db environment /var/lib/rpm cdb:0x401
29
D: opening db index /var/lib/rpm/Packages (none) mode=0x42
30
D: sanity checking 1 elements
31
D: running pre-transaction scripts
32
D: computing 17 file fingerprints
33
D: opening db index /var/lib/rpm/Name (none) mode=0x42
34
D: opening db index /var/lib/rpm/Basenames (none) mode=0x42
35
D: opening db index /var/lib/rpm/Group (none) mode=0x42
36
D: opening db index /var/lib/rpm/Requirename (none) mode=0x42
37
D: opening db index /var/lib/rpm/Providename (none) mode=0x42
38
D: opening db index /var/lib/rpm/Conflictname (none) mode=0x42
39
D: opening db index /var/lib/rpm/Obsoletename (none) mode=0x42
40
D: opening db index /var/lib/rpm/Triggername (none) mode=0x42
41
D: opening db index /var/lib/rpm/Dirnames (none) mode=0x42
42
D: opening db index /var/lib/rpm/Installtid (none) mode=0x42
43
D: opening db index /var/lib/rpm/Sigmd5 (none) mode=0x42
44
D: opening db index /var/lib/rpm/Sha1header (none) mode=0x42
45
Preparing packages...
46
D: computing file dispositions
47
D: 0x0000fd00 4096 10667163 23530388 /
48
D: ========== +++ zip-3.0-11.el7 x86_64-linux 0x2
49
D: read h# 1341 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: OK
50
D: erase: zip-3.0-11.el7 has 17 files
51
zip-3.0-11.el7.x86_64
52
D: erase 100644 1 ( 0, 0) 619 /usr/share/man/man1/zipsplit.1.gz
53
D: erase 100644 1 ( 0, 0) 819 /usr/share/man/man1/zipnote.1.gz
54
D: erase 100644 1 ( 0, 0) 951 /usr/share/man/man1/zipcloak.1.gz
55
D: erase 100644 1 ( 0, 0) 28496 /usr/share/man/man1/zip.1.gz
56
D: erase 100644 1 ( 0, 0) 3395 /usr/share/doc/zip-3.0/algorith.txt
57
D: erase 100644 1 ( 0, 0) 13167 /usr/share/doc/zip-3.0/WHERE
58
D: erase 100644 1 ( 0, 0) 15731 /usr/share/doc/zip-3.0/WHATSNEW
59
D: erase 100644 1 ( 0, 0) 6675 /usr/share/doc/zip-3.0/TODO
60
D: erase 100644 1 ( 0, 0) 6430 /usr/share/doc/zip-3.0/README.CR
61
D: erase 100644 1 ( 0, 0) 12748 /usr/share/doc/zip-3.0/README
62
D: erase 100644 1 ( 0, 0) 3412 /usr/share/doc/zip-3.0/LICENSE
63
D: erase 100644 1 ( 0, 0)210354 /usr/share/doc/zip-3.0/CHANGES
64
D: erase 040755 2 ( 0, 0) 6 /usr/share/doc/zip-3.0
65
D: erase 100755 1 ( 0, 0)100096 /usr/bin/zipsplit
66
D: erase 100755 1 ( 0, 0) 95984 /usr/bin/zipnote
67
D: erase 100755 1 ( 0, 0)100456 /usr/bin/zipcloak
68
D: erase 100755 1 ( 0, 0)215840 /usr/bin/zip
69
D: --- h# 1341 zip-3.0-11.el7.x86_64
70
D: removing "zip" from Name index.
71
D: removing 17 entries from Basenames index.
72
D: removing "Applications/Archiving" from Group index.
73
D: removing 13 entries from Requirename index.
74
D: removing 2 entries from Providename index.
75
D: removing 4 entries from Dirnames index.
76
D: removing 1 entries from Installtid index.
77
D: removing 1 entries from Sigmd5 index.
78
D: removing "ccee29b0ebdbefdec09bb543d7ef43882836c1da" from Sha1header index.
79
D: running post-transaction scripts
80
D: closed db index /var/lib/rpm/Sha1header
81
D: closed db index /var/lib/rpm/Sigmd5
82
D: closed db index /var/lib/rpm/Installtid
83
D: closed db index /var/lib/rpm/Dirnames
84
D: closed db index /var/lib/rpm/Triggername
85
D: closed db index /var/lib/rpm/Obsoletename
86
D: closed db index /var/lib/rpm/Conflictname
87
D: closed db index /var/lib/rpm/Providename
88
D: closed db index /var/lib/rpm/Requirename
89
D: closed db index /var/lib/rpm/Group
90
D: closed db index /var/lib/rpm/Basenames
91
D: closed db index /var/lib/rpm/Name
92
D: closed db index /var/lib/rpm/Packages
93
D: closed db environment /var/lib/rpm
Copied!
rpm take care of dependencies while removing a package and does not remove package dependencies. on the other hand if a package is required by other pacakage(d) rpm avoid removing that.The –nodeps (Do not check dependencies) option forcefully remove the rpm package from the system. But keep in mind removing particular package may break other working applications.
note:If you've made changes to a configuration file that was originally installed by RPM, your changes won't be lost if you erase the package.
What you can do is just run "rpm -qc packageName" which will show you which configuration files were installed on your system by an rpm. When you have uninstalled the rpm, you can search on your system if any of the files or their backups remain on your system and remove them manually.

rpm2cpio

From time to time, we might find it necessary to extract one or more files from a package file. One way to do this would be to:
    1.
    Install the package
    2.
    Make a copy of the file(s) you need
    3.
    Erase the package
An easier way would be to use rpm2cpio.
What Files Are In a RPM Package?
A rpm package is consist of some of files and directories which has been archived in cpio format, in addition some descriptions and dependencies have been added to that.
What does rpm2cpio do?
As the name implies, rpm2cpio takes an RPM package file and converts it to a cpio archive. next we need to open cpio archive in order to have orginal file structure.
In this case, the cpio options-i Extract one or more files from an archive, -vverboe, list the files processed, and -dCreate leading directories where needed.(We will talk about cpio in next courses)
rpm2cpio takes only only one argument, and even that's optional! The optional argument is the name of the package file to be converted. (If there is no filename specified on the command line, rpm2cpio will simply read from standard input and convert that to a cpio archive.)
1
2
zip-3.0-11.el7.x86_64.rpm
3
4
[[email protected] temp]# rpm2cpio zip-3.0-11.el7.x86_64.rpm > zip.cpio
5
6
7
zip-3.0-11.el7.x86_64.rpm zip.cpio
8
9
[[email protected] temp]# cpio -idv < zip.cpio
10
./usr/bin/zip
11
./usr/bin/zipcloak
12
./usr/bin/zipnote
13
./usr/bin/zipsplit
14
./usr/share/doc/zip-3.0
15
./usr/share/doc/zip-3.0/CHANGES
16
./usr/share/doc/zip-3.0/LICENSE
17
./usr/share/doc/zip-3.0/README
18
./usr/share/doc/zip-3.0/README.CR
19
./usr/share/doc/zip-3.0/TODO
20
./usr/share/doc/zip-3.0/WHATSNEW
21
./usr/share/doc/zip-3.0/WHERE
22
./usr/share/doc/zip-3.0/algorith.txt
23
./usr/share/man/man1/zip.1.gz
24
./usr/share/man/man1/zipcloak.1.gz
25
./usr/share/man/man1/zipnote.1.gz
26
./usr/share/man/man1/zipsplit.1.gz
27
1598 blocks
28
29
30
usr zip-3.0-11.el7.x86_64.rpm zip.cpio
31
[[email protected] temp]# tree usr/
32
usr/
33
├── bin
34
│ ├── zip
35
│ ├── zipcloak
36
│ ├── zipnote
37
│ └── zipsplit
38
└── share
39
├── doc
40
│ └── zip-3.0
41
│ ├── algorith.txt
42
│ ├── CHANGES
43
│ ├── LICENSE
44
│ ├── README
45
│ ├── README.CR
46
│ ├── TODO
47
│ ├── WHATSNEW
48
│ └── WHERE
49
└── man
50
└── man1
51
├── zip.1.gz
52
├── zipcloak.1.gz
53
├── zipnote.1.gz
54
└── zipsplit.1.gz
55
56
6 directories, 16 files
Copied!
While there's nothing wrong with using rpm2cpio to actually create a cpio archive file, it's takes a few more steps and uses a bit more disk space than is strictly necessary. A somewhat cleaner approach would be to pipe rpm2cpio's output directly into cpio:
1
[[email protected] temp]# rm -rf usr/
2
3
4
zip-3.0-11.el7.x86_64.rpm zip.cpio
5
6
[[email protected] temp]# rpm2cpio zip-3.0-11.el7.x86_64.rpm | cpio -t
7
./usr/bin/zip
8
./usr/bin/zipcloak
9
./usr/bin/zipnote
10
./usr/bin/zipsplit
11
./usr/share/doc/zip-3.0
12
./usr/share/doc/zip-3.0/CHANGES
13
./usr/share/doc/zip-3.0/LICENSE
14
./usr/share/doc/zip-3.0/README
15
./usr/share/doc/zip-3.0/README.CR
16
./usr/share/doc/zip-3.0/TODO
17
./usr/share/doc/zip-3.0/WHATSNEW
18
./usr/share/doc/zip-3.0/WHERE
19
./usr/share/doc/zip-3.0/algorith.txt
20
./usr/share/man/man1/zip.1.gz
21
./usr/share/man/man1/zipcloak.1.gz
22
./usr/share/man/man1/zipnote.1.gz
23
./usr/share/man/man1/zipsplit.1.gz
24
1598 blocks
25
26
zip-3.0-11.el7.x86_64.rpm zip.cpio
Copied!
we used the-t option to direct cpio to produce a "table of contents" of the archive created by rpm2cpio. This can make it much easier to get the right filename and path when you want to extract a file. An easier way to exctract would be rpm2cpio package.rpm | cpio id .
Warning! Becarefull when removing extracted package (usr vs /usr)

YUM

The YUM (Yellowdog Updater Modified) is an open-source command-line package-management utility for Linux operating systems using the RPM Package Manager. Yum allows automatic updates, package and dependency management, on RPM-based distributions.
As a high-level tool,like the Advanced Packaging Tool (APT) from Debian, yum works with software repositories (collections of packages), which can be accessed locally or over a network connection.
Yum is implemented as libraries in the Python programming language, with a small set of programs that provide a command-line interface. GUI-based wrappers such as yumex also exist.

/etc/yum.conf

The configuration file for yum and related utilities is located at /etc/yum.conf.
1
[[email protected] ~]# cat /etc/yum.conf
2
[main]
3
cachedir=/var/cache/yum/$basearch/$releasever
4
keepcache=0
5
debuglevel=2
6
logfile=/var/log/yum.log
7
exactarch=1
8
obsoletes=1
9
gpgcheck=1
10
plugins=1
11
installonly_limit=5
12
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
13
distroverpkg=centos-release
14
15
16
# This is the default, if you make this bigger yum won't see if the metadata
17
# is newer on the remote and so you'll "gain" the bandwidth of not having to
18
# download the new metadata and "pay" for it by yum not having correct
19
# information.
20
# It is esp. important, to have correct metadata, for distributions like
21
# Fedora which don't keep old packages around. If you don't like this checking
22
# interupting your command line usage, it's much better to have something
23
# manually check the metadata once an hour (yum-updatesd will do this).
24
# metadata_expire=90m
25
26
# PUT YOUR REPOS HERE OR IN separate files named file.repo
27
# in /etc/yum.repos.d
Copied!
This file contains one mandatory [main] section, which allows us to set Yum options that have global effect, and can also contain one or more [repository] sections, which allow us to set repository-specific options. However, it is recommended to define individual repositories in new or existing .repo files in the /etc/yum.repos.d/ directory.

/etc/yum.repos.d

YUM Repository configuration files are stored in /etc/yum.repos.d directory. It contains several .repo files.
1
[[email protected] ~]# ls /etc/yum.repos.d/
2
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
3
CentOS-CR.repo CentOS-Media.repo epel.repo
4
CentOS-Debuginfo.repo CentOS-Sources.repo epel-testing.repo
Copied!
Lets take a look at CentOS-Base.repo file:
1
[[email protected] ~]# cat /etc/yum.repos.d/CentOS-Base.repo
2
# CentOS-Base.repo
3
#
4
# The mirror system uses the connecting IP address of the client and the
5
# update status of each mirror to pick mirrors that are updated to and
6
# geographically close to the client. You should use this for CentOS updates
7
# unless you are manually picking other mirrors.
8
#
9
# If the mirrorlist= does not work for you, as a fall back you can try the
10
# remarked out baseurl= line instead.
11
#
12
#
13
14
[base]
15
name=CentOS-$releasever - Base
16
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
17
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
18
gpgcheck=1
19
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
20
21
#released updates
22
[updates]
23
name=CentOS-$releasever - Updates
24
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
25
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
26
gpgcheck=1
27
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
28
29
#additional packages that may be useful
30
[extras]
31
name=CentOS-$releasever - Extras
32
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
33
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
34
gpgcheck=1
35
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
36
37
#additional packages that extend functionality of existing packages
38
[centosplus]
39
name=CentOS-$releasever - Plus
40
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
41
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
42
gpgcheck=1
43
enabled=0
44
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Copied!
Repository configuration files tell yum information about the actual repository (where package files are physically located). While there are a number of optional elements, each .repo file is required to have:
    Repository ID - A one word unique repository ID e.g. [localrepo].
    Name - A human readable name for the repository e.g. name=Awesome Local Repo
    MirrorList : A mirror list is a list of URLs where Package repositories are stored/present.
    Baseurl - A URL to the repodata directory (where the actual files are kept). file://path, ftp://link, http://link, and https://link addresses are all valid options.
    Enabled - Whether or not to enable the repository for use when performing updates and installs e.g. enabled=1 (1 means "use this repository", 0 defines "do not use this repository").
    Gpgcheck - Enable/disable GPG signature checking (example: gpgcheck=1)
    Gpgkey - URL to the GPG key (example: gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6\
GPG is a digital signature check , which is used to verify the package is modified in between your downloads or after making the package, It help to verify the that you are installing the correct package with out any modification from 3 party or a hacker.
YUM can use numerous third party repositories to install packages automatically by resolving their dependencies issues.

List Enabled Yum Repositories

yum repolist list all enabled Yum repositories in your system:
1
[[email protected] ~]# yum repolist
2
Loaded plugins: fastestmirror, langpacks
3
Loading mirror speeds from cached hostfile
4
* base: bay.uchicago.edu
5
* epel: mirror.karneval.cz
6
* extras: mirror.atlanticmetro.net
7
* updates: mirror.atlanticmetro.net
8
repo id repo name status
9
base/7/x86_64 CentOS-7 - Base 9,911
10
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 12,725
11
extras/7/x86_64 CentOS-7 - Extras 434
12
updates/7/x86_64 CentOS-7 - Updates 1,614
13
repolist: 24,684
Copied!
To list all Enabled and Disabled Yum Repositories use yum repolist all command.

Install a Package with YUM

We can install new software on Red Hat/CentOS Linux with yum install packagename command from console.
Running this command first checks for existing YUM Repository configuration files in /etc/yum.repos.d/ directory. It reads each YUM Repository configuration file to get the information required to download and install new software, resolves software dependencies and installs the required RPM package files.
1
[[email protected] ~]# yum install zip
2
Loaded plugins: fastestmirror, langpacks
3
Loading mirror speeds from cached hostfile
4
* base: bay.uchicago.edu
5
* epel: epel.mirror.far.fi
6
* extras: mirror.atlanticmetro.net
7
* updates: mirror.atlanticmetro.net
8
Resolving Dependencies
9
--> Running transaction check
10
---> Package zip.x86_64 0:3.0-11.el7 will be installed
11
--> Finished Dependency Resolution
12
13
Dependencies Resolved
14
15
=======================================================================================
16
Package Arch Version Repository Size
17
=======================================================================================
18
Installing:
19
zip x86_64 3.0-11.el7 base 260 k
20
21
Transaction Summary
22
=======================================================================================
23
Install 1 Package
24
25
Total download size: 260 k
26
Installed size: 796 k
27
Is this ok [y/d/N]: y
28
Downloading packages:
29
zip-3.0-11.el7.x86_64.rpm | 260 kB 00:00:46
30
Running transaction check
31
Running transaction test
32
Transaction test succeeded
33
Running transaction
34
Installing : zip-3.0-11.el7.x86_64 1/1
35
Verifying : zip-3.0-11.el7.x86_64 1/1
36
37
Installed:
38
zip.x86_64 0:3.0-11.el7
39
40
Complete!
Copied!
use -y option if you do not like to be asked for confimation. If you have a rpm package use yum localinstall abc.rpm .

Removing a Package with YUM

yum remove packagename remove a package completely with their all dependencies.
1
[[email protected] ~]# yum remove zip
2
Loaded plugins: fastestmirror, langpacks
3
Resolving Dependencies
4
--> Running transaction check
5
---> Package zip.x86_64 0:3.0-11.el7 will be erased
6
--> Finished Dependency Resolution
7
8
Dependencies Resolved
9
10
=======================================================================================
11
Package Arch Version Repository Size
12
=======================================================================================
13
Removing:
14
zip x86_64 3.0-11.el7 @base 796 k
15
16
Transaction Summary
17
=======================================================================================
18
Remove 1 Package
19
20
Installed size: 796 k
21
Is this ok [y/N]: y
22
Downloading packages:
23
Running transaction check
24
Running transaction test
25
Transaction test succeeded
26
Running transaction
27
Erasing : zip-3.0-11.el7.x86_64 1/1
28
Verifying : zip-3.0-11.el7.x86_64 1/1
29
30
Removed:
31
zip.x86_64 0:3.0-11.el7
32
33
Complete!
Copied!
Same way the remove command will ask confirmation before removing a package. To disable it just add option -y .

Search for a Package using YUM

Use yum search function to search all the available packages to match the name of the package you specified.
1
[[email protected] ~]# yum search firefox
2
Loaded plugins: fastestmirror, langpacks
3
Loading mirror speeds from cached hostfile
4
* base: bay.uchicago.edu
5
* epel: epel.mirror.far.fi
6
* extras: mirror.atlanticmetro.net
7
* updates: mirror.atlanticmetro.net
8
================================ N/S matched: firefox =================================
9
firefox.x86_64 : Mozilla Firefox Web browser
10
firefox.i686 : Mozilla Firefox Web browser
11
firefox-noscript.noarch : JavaScript white list extension for Mozilla Firefox
12
firefox-pkcs11-loader.x86_64 : Helper script for Firefox that sets up the browser for
13
: authentication with Estonian ID-card
14
mozilla-adblockplus.noarch : Adblocking extension for Mozilla Firefox, Thunderbird, and
15
: SeaMonkey
16
mozilla-https-everywhere.noarch : HTTPS enforcement extension for Mozilla Firefox
17
mozilla-noscript.noarch : JavaScript white list extension for Mozilla Firefox
18
mozilla-requestpolicy.noarch : Firefox and Seamonkey extension that gives you control
19
: over cross-site requests
20
mozilla-ublock-origin.noarch : An efficient blocker for Firefox
21
webextension-token-signing.x86_64 : Firefox extension for signing with your eID on the
22
: web
23
24
Name and summary matches only, use "search all" for everything.
Copied!

Get Information of a Package using YUM

Withyum info packagename we can get information of a package before installing or an installed package:
2
bash: htop: command not found...
3
Similar command is: 'top'
4
[[email protected] ~]# yum info htop
5
Loaded plugins: fastestmirror, langpacks
6
Loading mirror speeds from cached hostfile
7
* base: bay.uchicago.edu
8
* epel: epel.mirror.far.fi
9
* extras: mirror.atlanticmetro.net
10
* updates: mirror.atlanticmetro.net
11
Available Packages
12
Name : htop
13
Arch : x86_64
14
Version : 2.2.0
15
Release : 1.el7
16
Size : 103 k
17
Repo : epel/x86_64
18
Summary : Interactive process viewer
19
URL : http://hisham.hm/htop/
20
License : GPLv2+
21
Description : htop is an interactive text-mode process viewer for Linux, similar to
22
: top(1).
Copied!

Get information about dependencies of a package

Use yum deplist command to know about dependencies of a package which would be installed on our system:
1
[[email protected] ~]# yum deplist htop
2
Loaded plugins: fastestmirror, langpacks
3
Loading mirror speeds from cached hostfile
4
* base: bay.uchicago.edu
5
* epel: mirror.23media.de
6
* extras: mirror.atlanticmetro.net
7
* updates: mirror.atlanticmetro.net
8
package: htop.x86_64 2.2.0-1.el7
9
dependency: libc.so.6(GLIBC_2.15)(64bit)
10
provider: glibc.x86_64 2.17-222.el7
11
dependency: libgcc_s.so.1()(64bit)
12
provider: libgcc.x86_64 4.8.5-28.el7_5.1
13
dependency: libgcc_s.so.1(GCC_3.0)(64bit)
14
provider: libgcc.x86_64 4.8.5-28.el7_5.1
15
dependency: libgcc_s.so.1(GCC_3.3.1)(64bit)
16
provider: libgcc.x86_64 4.8.5-28.el7_5.1
17
dependency: libm.so.6()(64bit)
18
provider: glibc.x86_64 2.17-222.el7
19
dependency: libm.so.6(GLIBC_2.2.5)(64bit)
20
provider: glibc.x86_64 2.17-222.el7
21
dependency: libncursesw.so.5()(64bit)
22
provider: ncurses-libs.x86_64 5.9-14.20130511.el7_4
23
dependency: libtinfo.so.5()(64bit)
24
provider: ncurses-libs.x86_64 5.9-14.20130511.el7_4
25
dependency: rtld(GNU_HASH)
26
provider: glibc.x86_64 2.17-222.el7
27
provider: glibc.i686 2.17-222.el7
Copied!
yum installautomatically installs all of them.

Yum Provides Function

yum provide finds packages that provide the queried file:
1
[[email protected] ~]# yum provides /etc/updatedb.conf
2
Loaded plugins: fastestmirror, langpacks
3
Loading mirror speeds from cached hostfile
4
* base: bay.uchicago.edu
5
* epel: epel.besthosting.ua
6
* extras: mirror.atlanticmetro.net
7
* updates: mirror.atlanticmetro.net
8
mlocate-0.26-8.el7.x86_64 : An utility for finding files by name
9
Repo : base
10
Matched from:
11
Filename : /etc/updatedb.conf
12
13
14
15
mlocate-0.26-6.el7.x86_64 : An utility for finding files by name
16
Repo : @anaconda
17
Matched from:
18
Filename : /etc/updatedb.conf
Copied!
also we can useyum whatprovide /*filename instead.

List all Available Packages

yum list list all the available packages in the Yum database.
1
[[email protected] ~]# yum list
Copied!

List all Installed Packages using YUM

1
[[email protected] ~]# yum list installed
Copied!

Working with yum Cache

By default, yum deletes downloaded data files when they are no longer needed after a successful operation. This minimizes the amount of storage space that yum uses. However, we can enable caching, so that the package files downloaded by yum stay in cache directories. By using cached data, you can carry out certain operations without a network connection, we can also copy packages stored in the caches and reuse them elsewhere.
Yum stores temporary files in the/var/cache/yum/$basearch/$releasever/directory,
1
[[email protected] ~]# ls /var/cache/yum/x86_64/7/
2
base epel extras timedhosts timedhosts.txt updates
Copied!
Each configured repository has one subdirectory.T o change the default cache location, modify the cachedir option in the [main] section of the /etc/yum.confconfiguration file.
Enabling the cache
To retain the cache of packages after a successful installation, we can enable the cache editing keppcache = 1 in the [main] section of/etc/yum.conf.
To download and make usable all the metadata for the currently enabled yum repositories, use yum makecache command.It makes sure that the cache is fully up to date with all metadata.This make sure that the cache is fully up to date with all metadata. To set the time after which the metadata will expire, use the metadata-expire setting in/etc/yum.conf.
Using yum in Cache-only Mode
To carry out a yum command without a network connection, add the -C (not -c )or --cacheonly command-line option. With this option, yum proceeds without checking any network repositories, and uses only cached files. In this mode, yum may only install packages that have been downloaded and cached by a previous operation.
1
[[email protected] ~]# yum -C install zip
2
Loaded plugins: fastestmirror, langpacks
3
Resolving Dependencies
4
--> Running transaction check
5
---> Package zip.x86_64 0:3.0-11.el7 will be installed
6
--> Finished Dependency Resolution
7
8
Dependencies Resolved
9
10
=======================================================================================
11
Package Arch Version Repository Size
12
=======================================================================================
13
Installing:
14
zip x86_64 3.0-11.el7 base 260 k
15
16
Transaction Summary
17
=======================================================================================
18
Install 1 Package
19
20
Total download size: 260 k
21
Installed size: 796 k
22
Is this ok [y/d/N]:
Copied!
clearing the yum caches
It is often useful to remove entries accumulated in the /var/cache/yum/ directory. If we remove a package from the cache, we do not affect the copy of the software installed on our system. To remove all entries for currently enabled repositories from the cache, run yum clean all as a root.

Check for Available Updates using Yum

use yum check-update To find how many of installed packages on our system have updates available:
1
[[email protected] ~]# yum check-update
2
Loaded plugins: fastestmirror, langpacks
3
Loading mirror speeds from cached hostfile
4
* base: bay.uchicago.edu
5
* epel: epel.mirror.far.fi
6
* extras: mirror.atlanticmetro.net
7
* updates: mirror.atlanticmetro.net
8
9
ModemManager.x86_64 1.6.10-1.el7 base
10
ModemManager-glib.x86_64 1.6.10-1.el7 base
11
NetworkManager.x86_64 1:1.10.2-16.el7_5 updates
12
NetworkManager-adsl.x86_64 1:1.10.2-16.el7_5 updates
13
NetworkManager-bluetooth.x86_64 1:1.10.2-16.el7_5 updates
14
NetworkManager-glib.x86_64 1:1.10.2-16.el7_5 updates
15
NetworkManager-libnm.x86_64 1:1.10.2-16.el7_5 updates
16
NetworkManager-ppp.x86_64 1:1.10.2-16.el7_5 updates
17
NetworkManager-team.x86_64 1:1.10.2-16.el7_5 updates
18
NetworkManager-tui.x86_64 1:1.10.2-16.el7_5 updates
19
NetworkManager-wifi.x86_64 1:1.10.2-16.el7_5 updates
20
...
21
<output has been truncated>
Copied!

Update System using Yum

yum update keep our system up-to-date with all security and binary package updates
1
[[email protected] ~]# yum update
2
Loaded plugins: fastestmirror, langpacks
3
Loading mirror speeds from cached hostfile
4
* base: bay.uchicago.edu
5
* epel: epel.mirror.far.fi
6
* extras: mirror.atlanticmetro.net
7
* updates: mirror.atlanticmetro.net
8
Resolving Dependencies
9
--> Running transaction check
10
---> Package ModemManager.x86_64 0:1.6.0-2.el7 will be updated
11
---> Package ModemManager.x86_64 0:1.6.10-1.el7 will be an update
12
...
13
--> Finished Dependency Resolution
14
15
Dependencies Resolved
16
17
=======================================================================================
18
Package Arch Version Repository
19
Size
20
=======================================================================================
21
Installing:
22
grub2 x86_64 1:2.02-0.65.el7.centos.2 base 29 k
23
replacing grub2.x86_64 1:2.02-0.64.el7.centos
24
grub2-tools x86_64 1:2.02-0.65.el7.centos.2 base 1.8 M
25
replacing grub2-tools.x86_64 1:2.02-0.64.el7.centos
26
grub2-tools-extra x86_64 1:2.02-0.65.el7.centos.2 base 993 k
27
replacing grub2-tools.x86_64 1:2.02-0.64.el7.centos
28
grub2-tools-minimal x86_64 1:2.02-0.65.el7.centos.2 base 170 k
29
replacing grub2-tools.x86_64 1:2.02-0.64.el7.centos
30
kernel x86_64 3.10.0-862.14.4.el7 updates 46 M
31
Updating:
32
ModemManager x86_64 1.6.10-1.el7 base 735 k
33
ModemManager-glib x86_64 1.6.10-1.el7 base 231 k
34
NetworkManager x86_64 1:1.10.2-16.el7_5 updates 1.7 M
35
NetworkManager-adsl x86_64 1:1.10.2-16.el7_5 updates 159 k
36
NetworkManager-bluetooth x86_64 1:1.10.2-16.el7_5 updates 179 k
37
...
38
mesa-libwayland-egl x86_64 17.2.3-8.20171019.el7 base 17 k
39
unbound-libs x86_64 1.6.6-1.el7 base 405 k
40
volume_key-libs x86_64 0.3.9-8.el7 base 140 k
41
42
Transaction Summary
43
=======================================================================================
44
Install 5 Packages (+20 Dependent packages)
45
Upgrade 578 Packages
46
47
Total size: 552 M
48
Is this ok [y/d/N]: y
49
...
Copied!

Updating a Package using YUM

yum update packagenamewill update a package and automatically resolves all dependencies issues and install them.
1
[[email protected] ~]# yum update firefox -y
2
Loaded plugins: fastestmirror, langpacks
3
Loading mirror speeds from cached hostfile
4
* base: bay.uchicago.edu
5
* epel: epel.mirror.far.fi
6
* extras: mirror.atlanticmetro.net
7
* updates: mirror.atlanticmetro.net
8
Resolving Dependencies
9
--> Running transaction check
10
---> Package firefox.x86_64 0:52.2.0-2.el7.centos will be updated
11
---> Package firefox.x86_64 0:60.3.0-1.el7.centos will be an update
12
--> Processing Dependency: nss >= 3.36.0 for package: firefox-60.3.0-1.el7.centos.x86_64
13
--> Processing Dependency: nspr >= 4.19.0 for package: firefox-60.3.0-1.el7.centos.x86_64
14
--> Processing Dependency: libdbus-1.so.3(LIBDBUS_1_3)(64bit) for package: firefox-60.3.0-1.el7.centos.x86_64
15
...
16
Dependencies Resolved
17
=======================================================================================
18
Package Arch Version Repository Size
19
=======================================================================================
20
Updating:
21
firefox x86_64 60.3.0-1.el7.centos updates 91 M
22
Updating for dependencies:
23
dbus x86_64 1:1.10.24-7.el7 base 245 k
24
dbus-libs x86_64 1:1.10.24-7.el7 base 169 k
25
dbus-x11 x86_64 1:1.10.24-7.el7 base 47 k
26
...
27
Transaction Summary
28
=======================================================================================
29
Upgrade 1 Package (+10 Dependent packages)
30
31
Total size: 93 M
32
Downloading packages:
33
Running transaction check
34
Running transaction test
35
Transaction test succeeded
36
Running transaction
37
Updating : nspr-4.19.0-1.el7_5.x86_64 1/22
38
Updating : nss-util-3.36.0-1.el7_5.x86_64 2/22
39
...
40
Cleanup : 1:dbus-libs-1.6.12-17.el7.x86_64 20/22
41
Cleanup : nspr-4.13.1-1.0.el7_3.x86_64 21/22
42
Cleanup : nss-softokn-freebl-3.28.3-6.el7.x86_64 22/22
43
Verifying : 1:dbus-x11-1.10.24-7.el7.x86_64 1/22
44
Verifying : 1:dbus-libs-1.10.24-7.el7.x86_64 2/22
45
Verifying : firefox-60.3.0-1.el7.centos.x86_64 3/22
46
...
47
Verifying : firefox-52.2.0-2.el7.centos.x86_64 21/22
48
Verifying : nss-softokn-freebl-3.28.3-6.el7.x86_64 22/22
49
50
Updated:
51
firefox.x86_64 0:60.3.0-1.el7.centos
52
53
Dependency Updated:
54
dbus.x86_64 1:1.10.24-7.el7 dbus-libs.x86_64 1:1.10.24-7.el7
55
dbus-x11.x86_64 1:1.10.24-7.el7 nspr.x86_64 0:4.19.0-1.el7_5
56
nss.x86_64 0:3.36.0-7.el7_5 nss-softokn.x86_64 0:3.36.0-5.el7_5
57
nss-softokn-freebl.x86_64 0:3.36.0-5.el7_5 nss-sysinit.x86_64 0:3.36.0-7.el7_5
58
nss-tools.x86_64 0:3.36.0-7.el7_5 nss-util.x86_64 0:3.36.0-1.el7_5
59
60
Complete!
Copied!
If you have a rpm package you can use yum localupdate abc.rpm .

YUM update vs YUM upgrade

yum upgrade and yum update will perform the same function that update to the latest current version of package.
yum upgrade forces the removal of obsolete packages, while yum update may or may not also do this. The removal of obsolete packages can be risky, as it may remove packages that you use. This makes yum update the safer option.
note: The behaviour might be different based on your distribution and version.

Working with Group Packages

In Linux, number of packages are bundled to particular group , called Group Packages. Instead of working with individual packages with yum, we can work particular group that will install/remove/update all the related packages that belongs to the group.
1
# yum grouplist :
2
# yum groupinstall 'MySQL Database'
3
# yum groupupdate 'DNS Name Server'
4
# yum groupremove 'DNS Name Server'
Copied!

YUM Shell

Yum utility provides a custom shell where you can execute multiple commands.
1
[[email protected] ~]# yum shell
2
Loaded plugins: fastestmirror, langpacks
3
> list
4
list list-sec list-security list-updateinfo
5
> group
6
group groupinfo grouplist groups
7
grouperase groupinstall groupremove groupupdate
8
> quit
9
Leaving Shell
Copied!

yumdownloader

How do I use yum to download a package without installing it? There are multiple ways in which you can download a yum package without installing it. The 2 most commonly used methods are described here in the post.
    1.
    using the “downloadonly” plugin for yum
    2.
    using “yumdownloader” utility.
Method 1 : using the “downloadonly” plugin for yum:
First install the package including “downloadonly” plugin:
1
(RHEL5)
2
# yum install yum-downloadonly
3
4
(RHEL6)
5
# yum install yum-plugin-downloadonly
Copied!
syntax:
1
yum install --downloadonly --downloaddir=[directory] [package]
Copied!
If you do not use --downloaddir option, it would be saved in /var/cache/yum/ in rhel-{arch}-channel/packages directory.
example:
1
yum install --downloadonly --downloaddir=/tmp firefox
Copied!
Method 2 : using the “yumdownloader” utility
First install the yum-utils package:
1
yum install yum-utils
Copied!
syntax:
1
yumdownloader --destdir [directory] [package]
Copied!
example:
1
yumdownloader --destdir /tmp firefox
Copied!
tryyumdownloader --help to see some of usefull switches such as :
1
--urls Instead of downloading RPMs, list the URLs that would be downloaded.
2
--resolve When downloading RPMs, resolve dependencies and also download the required packages.
3
--source Instead of downloading the binary RPMs, download the source RPMs
4
...
Copied!
the --resolve switch is usefull inorder to download a package ant its dependencies and lets us to use them in other system.

to view history of Yum commands (update, install, remove)

We can either use yum history command :
1
[[email protected] ~]# yum history
2
Loaded plugins: fastestmirror, langpacks
3
ID | Login user | Date and time | Action(s) | Altered
4
-------------------------------------------------------------------------------
5
11 | payam <payam> | 2018-12-05 10:02 | Update | 11
6
10 | payam <payam> | 2018-12-04 14:54 | Erase | 1
7
9 | payam <payam> | 2018-12-04 14:45 | Install | 1
8
8 | payam <payam> | 2018-12-04 14:44 | Erase | 1 <
9
7 | payam <payam> | 2018-12-03 06:03 | Erase | 3 >
10
6 | payam <payam> | 2018-11-19 05:14 | I, U | 3
11
5 | payam <payam> | 2018-11-18 03:46 | Install | 1
12
4 | payam <payam> | 2018-10-20 13:01 | Install | 1
13
3 | payam <payam> | 2018-10-13 03:38 | Install | 12
14
2 | payam <payam> | 2018-08-26 04:48 | I, U | 3
15
1 | System <unset> | 2017-10-28 11:18 | Install | 1318
16
history list
Copied!
or see yum log file in /var/log/yum directory:
1
[[email protected] ~]# tail -5 /var/log/yum.log
2
Dec 05 10:02:27 Updated: nss-sysinit-3.36.0-7.el7_5.x86_64
3
Dec 05 10:02:27 Updated: nss-3.36.0-7.el7_5.x86_64
4
Dec 05 10:02:37 Updated: firefox-60.3.0-1.el7.centos.x86_64
5
Dec 05 10:02:37 Updated: nss-tools-3.36.0-7.el7_5.x86_64
6
Dec 05 10:02:37 Updated: 1:dbus-x11-1.10.24-7.el7.x86_64
Copied!

Summary

Fedora Family System:
    Red Hat Package Manager (rpm):
      low-level or underlying packet manager
    Yellowdog Updater (yum):
      The high-level package manager differs between distribution but yum is commonly used
    Dandified Yum (dnf):
      It is the next-generation version of yum
.
.
.
sources: