Click here for "Error Codes for Commercial Air Conditioners".(Japanese Version)

Package management with YUM

Package management with YUM

CentOS and Fedora have YUM (Yellow dog Updater Modified) that automatically resolves RPM package dependencies and installs them.
※This is equivalent to the package management system (APT tool) used in Debian GNU/Linux and Vine Linux.

The YUM configuration file consists of the following
/etc/yum.conf
/etc/yum.repos.d

●Example of yum.conf file

[root@Lion ~]# cat /etc/yum.conf
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
[main]cachedir=/var/cache/yum/$basearch/$releaseverkeepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

Under the /etc/yum.repos.d directory, the configuration files for repository information are stored.
If you want to get more packages, add a configuration file for repository information.

[root@Lion ~]# ls -l /etc/yum.repos.d
Total 32
-rw-r--r--. 1 root root 1664 November 23 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 November 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 November 23 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 November 23 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 November 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 November 23 2018 CentOS-Vault.repo
-rw-r--r--. 1 root root 314 November 23 2018 CentOS-fasttrack.repo

●Format of the yum command

yum [options] command [package name, etc.]

Basic operations of the yum command

yum install Package Name
(Install the package and the packages it needs at the same time)
yum update Package Name
(If the specified package is installed, it will be updated. If the package is not specified, the entire system will be updated.)
yum erase Package Name
(Uninstall the package. You will be prompted to confirm that you also want to remove packages that depend on the specified package.)

●The main commands of yum

Package operation relations

command Execution contents
install Install the package
reinstall Reinstall the package
downgrade Downgrading a package
erase Remove the package
update Update the system package.
update-minimal Update only "Important update."
upgrade Update the package while taking into account packages that are no longer needed.
distribution-synchronization Synchronize installed packages to the latest available version
localinstall Install by specifying the package file (RPM file)
localupdate Update by specifying the package file (RPM file)

Information-related commands

command Execution contents
info Display the details of a package or package group
list Display a list of package groups
deplist Display a list of package dependencies
groups Display information on package groups
search Searching for package details with a specified string
provides Specify a file, etc., and search for packages that provide the corresponding file.
repolist View the configuration of the software repository.
version Display the repository versions available to the host

Maintenance-related commands and others

command Execution contents
check Check the rpm database for problems.
check-update Check which packages are available for updating.
clean Delete the cache data.
shell Run an interactive shell (yum shell)
updateinfo View repository updates.

●The main options of the yum command

Short options Long options Meaning
-y --assumeyes Assume that all queries are answered with "yes".
--assumeno Assume that all queries are answered with "no".
-t --tolerant silence an error
-R <minute> --randomwait=<minute> Specify the maximum waiting time.
-c <configuration file> --config=<configuration file> Specify the configuration file
--installroot=<Location> Specify the installation location
--downloaddir=<Location> Specify the download destination
--downloadonly Just download the file.
-C --cacheonly Don't download package information, just use the cache
-x <Package> --exclude=<Package> Specify which packages to exclude (wildcards can be used)
--color=<Specify> Colorize the output message
Specify with "always", "auto", or "never".
-q --quiet Do not output messages at runtime
-v --verbose Output a detailed message

●Update confirmation

When you run "yum check-update", it will show you a list of installed packages that have updates.

[root@Lion ~]# yum check-update
# yum check-update
Loaded plugins:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jpImageMagick.x86_64 6.7.8.9-15.el7_2 base
ImageMagick-perl.x86_64 6.7.8.9-15.el7_2 base
NetworkManager.x86_64 1:1.4.0-20.el7_3 updates
NetworkManager-libnm.x86_64 1:1.4.0-20.el7_3 updates
NetworkManager-team.x86_64 1:1.4.0-20.el7_3 updates
NetworkManager-tui.x86_64 1:1.4.0-20.el7_3 updates
SDL.x86_64 1.2.15-14.el7 base(abbreviation)yum.noarch 3.4.3-150.el7.centos base
yum-langpacks.noarch 0.4.2-7.el7 base
yum-plugin-fastestmirror.noarch 1.1.31-40.el7 base
yum-utils.noarch 1.1.31-40.el7 base
zip.x86_64 3.0-11.el7 base
zlib.x86_64 1.2.7-17.el7 base
zlib-devel.x86_64 1.2.7-17.el7 base

●Check if the package is already installed.

To check if a package is already installed on your system, use the "list installed" command.
In the example below, we are checking if httpd is installed.

[root@Lion ~]# yum list installed httpd
Loaded plugins:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
preinstalled package
httpd.x86_64 2.4.6-31.el7.centos @anaconda

●Search for packages

To search for a package using keywords in the yum command, run the search subcommand.
In the example, we get the expect package list.

[root@Lion ~]# yum search expect
Loaded plugins:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
======================================= N/S matched: expect ========================================
pexpect.noarch : Pure Python Expect-like module
expect.x86_64 : A program-script interaction and testing utility
expect-devel.i686 : A program-script interaction and testing utility
expect-devel.x86_64 : A program-script interaction and testing utility
expectk.x86_64 : A program-script interaction and testing utility

●Update a specific package

To update a specific package, specify the update subcommand.
In the example, we are updating the openssl package。

[root@Lion ~]# yum update openssl
Loaded plugins:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
working on a dependency solution.
--> Performing transaction verification.
---> Updated package openssl.x86_64 1:1.0.1e-51.el7_2.4
---> Update package openssl.x86_64 1:1.0.1e-60.el7_3.1
--> Handling dependencies: openssl-libs(x86-64) = 1:1.0.1e-60.el7_3.1 : 1:openssl-1.0.1e-60.el7_3.1.x86_64
--> Perform transaction verification
---> Updated package openssl-libs.x86_64 1:1.0.1e-51.el7_2.4
(abbreviation)
--> Finish dependency resolution.Dependency solved.===================================================
Package architectureー version Repositories Capacity
===================================================
更新します:
openssl x86_64 1:1.0.1e-60.el7_3.1 updates 713 k
Update on dependency related:
openssl-devel x86_64 1:1.0.1e-60.el7_3.1 updates 1.2 M
openssl-libs x86_64 1:1.0.1e-60.el7_3.1 updates 959 kTransaction Summary
====================================================
update 1 Package (+Package of 2 dependencies)Total download capacity: 2.8 M
Is this ok [y/d/N]:y    ←Enter y
(The following is omitted)

●Run the system update.

When you run "yum update", all the installed packages will be updated to the latest version.

[root@Lion ~]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: rsync.atworks.co.jp
* base: rsync.atworks.co.jp
* extras: rsync.atworks.co.jp
* updates: rsync.atworks.co.jp
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package ImageMagick.i386 0:6.2.8.0-4.el5_5.3 set to be updated
---> Package NetworkManager.i386 1:0.7.0-10.el5_5.2 set to be updated
---> Package NetworkManager-glib.i386 1:0.7.0-10.el5_5.2 set to be updated
---> Package NetworkManager-gnome.i386 1:0.7.0-10.el5_5.2 set to be updated(中略)--> Running transaction check
---> Package tzdata-java.i386 0:2010l-1.el5 set to be updated
extras/filelists_db | 195 kB 00:00
--> Finished Dependency ResolutionDependencies Resolved===========================================================
Package Arch Version   Repository Size
===========================================================
Installing:
kernel i686 2.6.18-194.32.1.el5 updates 17 M
Updating:
ImageMagick i386 6.2.8.0-4.el5_5.3 updates 3.3 M
NetworkManager i386 1:0.7.0-10.el5_5.2 updates 1.0 M
NetworkManager-glib i386 1:0.7.0-10.el5_5.2 updates 82 k
NetworkManager-gnome i386 1:0.7.0-10.el5_5.2 updates 327 k
apr i386 1.2.7-11.el5_5.3 updates 123 k(abbreviation)Transaction Summary
===========================================================
Install 2 Package(s)
Upgrade 110 Package(s)

Total download size: 347 M
Is this ok [y/N]:y    ←Enter y
Downloading Packages:
(1/112): avahi-glib-0.6.16-9.el5_5.i386.rpm | 15 kB 00:00
(2/112): device-mapper-event-1.02.39-1.el5_5.2.i386.rpm | 20 kB 00:00
(The following is omitted)

●Uninstall the package

To uninstall a package, execute the following.
In the example, we are removing the openssl package

[root@Lion ~]# yum remove openssl

●View and install groups

RPM packages can be divided into a number of groups.
With YUM, you can install packages by groups.
You can check what kind of groups are available by using "yum grouplist

[root@Lion ~]# yum grouplist
Loaded plugins:fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Available environment groups:
Minimal installation
Compute Node
infrastructure server
File and Print Servers
Basic Web Server
virtualized host
Server (Use GUI)
GNOME Desktop
KDE Plasma Workspaces
Development and creative workstations
Available groups
Graphical Management Tools
Console Internet Tools
System Administration
System Administration Tools
Smart Card Support
Security Tools
Legacy UNIX compatibility
Compatibility Library
Scientific Support
Development Tools
Done

To install all the packages related to "Basic Web Server" at once

[root@Lion ~]# yum groupinstall "Basic Web Server"
Copied title and URL