Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
What is YUM?
YUM (Yellowdog Updater Modified) is an open source command line and graphic-based package management tool for Linux systems based on RPM (RedHat package manager). It allows users and system administrators to easily install, update, delete, or search for software packages on the system.
It was developed and distributed open source by Seth Vidal under the GPL (General Public License), which means anyone can download and access the code to fix bugs and develop custom packages.
YUM uses a number of third-party repositories to install packages automatically by resolving dependencies between them.
YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool for RPM (RedHat Package Manager) based Linux systems. It allows users and system administrator to easily install, update, remove or search software packages on a systems. It was developed and released by Seth Vidal under GPL (General Public License) as an open source, means anyone can allowed to download and access the code to fix bugs and develop customized packages. YUM uses numerous third party repositories to install packages automatically by resolving their dependencies issues.
Yum is a Shell front-end package manager in Fedora and RedHat as well as SUSE.
Based on RPM package management, yum can automatically download and install RPM packages from specified servers. It can automatically handle dependencies and install all dependent software packages at one time without tedious downloading and installation. In addition, it provides commands to find, install, and delete one, a group, or even all packages.
It can be seen as an improvement on RPM to solve the software package dependency problem of PRM. Yum stores all RPM packages on the server side and records the dependencies between each package in a file. When an administrator installs an RPM package using yum, Yum first downloads the dependency file of the package from the server side. By analyzing this file, download all relevant RPM packages from the server and install (or upgrade) them at once.
Yum syntax and common commands
yum [options] [command] [package ...]
Copy the code
- Options: Options include -h (help), -y (select all “yes” when prompted during installation), -q (do not display the installation process), and so on.
- Command: Operation to be performed.
- Package: indicates the name of the installation package.
For example, the following commands:
-
Yum check-update: Lists all software that can be updated
-
Yum Update: Updates all software
-
Yum install
: installs the specified software, usually in combination with -y -
Yum localinstall
: installs software with a specific RPM suffix, usually in combination with -y -
Yum update
: updates the specified software -
Yum List: Lists all installable software
-
Yum List updates: Lists all updatable packages
-
Yum List Installed: Lists all installed packages
-
Yum List available: View all available packages
-
Yum List all: Equivalent to yum List, lists all packages, installed and available.
-
Yum List Extras: Lists all installed packages that are not in yum Repository. Extras here has nothing to do with [Extras] in the REPO file listed later
-
Yum search
: yum search
-
Yum info
: Obtain software package information -
Yum Info: Lists information about all packages
-
Yum info updates: Lists all updatable package information
-
Yum Info Installed: Lists all installed software package information
-
Yum Info Extras: Lists all installed packages that are not in the Yum Repository
-
Yum remove
: deletes the software package -
Yum deplist
: check package dependencies -
Clear cache command:
Yum Clean packages: clear the headers in the cache directory yum Clean headers: Clear the headers in the cache directory yum clean oldheaders: Headers yum clean, yum clean all (= yum clean packages; Yum clean oldheaders) : clears packages and oldheaders in the cache directory
yum provides <file>
: Checks which installation package (software package) contains a library or file
For example, if you are installing software in Linux and a message is displayed indicating that a library is missing or a file is missing, you can use yum provides XXX to check which package provides the library, that is, which package or installation package contains the library.
For example, see which package provides the libstdc++.so.6 library.
yum provides libstdc++.so.6 Copy the code
yum repolist
: View the list of YUM repositories.
View the currently included yum repository:
# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile repo id repo name status CityFan/7/x86_64 City Fan Repo 766 epel/7/x86_64 EPEL forRedhat /centos 7-x86_64 13,674 Qcloud centos extras/7/x86_64 500 Google chrome Google chrome 3 mariadb MariaDB 100 mariadb5 MariaDB 40 mysql-connectors-community/x86_64 MySQL Connectors Community 212 Mysql-tools-community /x86_64 mysql tools community 132 mysql80-community/x86_64 mysql 8.0 community Server 283 OS /7/x86_64 Qcloud centos OS-x86_64 10 072 packs-microsoft-com-prod packs-microsoft-com-prod 993 Updates /7/x86_64 Qcloud centos updates - x86_64 2,751 repolist: 29,526Copy the code
Check whether yum is installed
Yum is also software, so you can verify that you have it installed before using it.
# rpm -qa | grep yumYum - langpacks - 0.4.2-7. El7. Noarch yum - rule 3.4.3-150. El7. Centos. Noarch yum - utils - 1.1.31-40. El7. Noarch Yum - metadata - parser - 1.1.4-10. El7. X86_64 PackageKit - yum - 1.1.10-1. El7. Centos. X86_64 Yum - plugin - fastestmirror - 1.1.31-40. El7. NoarchCopy the code
You can see that YUM has been installed.
For installing yum using RPM command, check how to install yum in Linux
Yum source
As you can see from the introduction, YUM downloads RPMS and related dependencies from one location. When using yum to install software, you must specify a location to download the RPM package. Yum will find and download the installation package from this location. This location is called the yum source.
Yum source refers to the source of the software installation package.
This is why when installing software, it is common to install or configure the YUM or mirror source before downloading it. Because the source of the package must be specified, it can only be found and downloaded from the YUM source at install time.
The yum source can be a network yum source or a local address YUM source.
The default YUM install repository uses a foreign repository source address, which results in sometimes slow downloads during installation, extremely easy interruptions and installation failures, etc. Therefore, we usually use the mirror source of the yum repository in China. The recommended yum sources are 163, Tsinghua, Aliyun, Tencent, USTC and so on.
A separate section describes how to configure the correct and detailed yum domestic mirror source.
Yum Source configuration file (REPo file)
The yum configuration file is located in the /etc/yom.repos. d/ directory. The extension name of the file is. Repo.
# ls /etc/yum.repos.d/Centos-base. Repo Google -chrome. Repo Microsoft -prod. Repo centos-pel. Repo mariadb5.4. repo mysql-community city-fan.repo MariaDB.repo mysql-community-source.repoCopy the code
The centos-base. repo file is the basic YUM source file from which basic software can be downloaded. To install other software, you can create a. Repo repository source configuration file that specifies the source address of the YUM network for installing the software. During installation, you can search for and download the software from this file.
Repo yum yum yum yum yum yum yum yum yum
# cat CentOS-Base.repo
[extras]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/extras/$basearch/
name=Qcloud centos extras - $basearch
[os]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/os/$basearch/
name=Qcloud centos os - $basearch
[updates]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/updates/$basearch/
name=Qcloud centos updates - $basearch
Copy the code
A REPo file is a configuration file for the YUM source (repository). Typically, a repo file defines the details of one or more repositories, such as where to download software packages that need to be installed or upgraded, and the Settings in the repo file are read and applied by YUM.
Repo file Description (Common properties)
-
[ServerID] : The serverID is used to distinguish different repositories and must have a unique name. Can be seen as the name of the software source, which is read and recognized by YUM. Put it in square brackets.
-
$releasever, $basearch, $releasever, $basearch, $releasever, $basearch, $basearch
-
Mirrorlist = url: / / : Mirrorlist specifies a URL address that is a list of multiple source mirror addresses. When the user installs or upgrades the software through YUM, Yum attempts to download from the list of mirror sources in sequence. If downloading from one mirror source fails, it automatically tries the next one in the list. If the target software package is not downloaded after the list is traversed, an error is thrown to the user.
-
Baseurl =url:// : Baseurl =url:// : Baseurl =url:// : Baseurl is the most important part of the yum source setup. The url supports three protocols: http://ftp:// file://. The directory to which the URL points must be one level above the Repository header directory. Variables like $releasever $basearch are also supported.
-
Gpgcheck =[1 or 0] : Gpgchkeck = Indicates whether GPG check is performed. If no gpGCHkeck check is performed, GPG check is performed by default.
-
Gpgkey = URL :// : gpgkey specifies the address of the KEY file and supports HTTP, FTP, and file.
-
Exclude = : exclude Specifies the software that is excluded from the installation or upgrade list. You can use a wildcard character to exclude the software. Items in the list must be separated by Spaces.
-
Failovermethod =priority: Failovermethode Determines the order in which YUM selects when multiple sources are available. This property has two options: roundrobin and Priority. Roundrobin is selected randomly. If the connection fails, the next one is used. Priority starts from the first url in the order of the url. If not specified, the default is roundrobin.
-
Enabled =[1 or 0] : If a repository is set to Enabled =0, yum does not use the repository as the source for installing or upgrading software packages. With this option, you can enable or disable software repositories.
The $RELEasever variable represents the release and is usually a number like 8, 9, and 10. The version of the distribution is obtained from the distroverpkg in the [main] section or, if not, from the Redhat-Release package.
$basearch
Variables represent the base architecture group of the system, which can be I386, X86_64, PPC equivalent. For example, I686 and Athlon belong to i386, alpha and AlphaEV6 belong to alpha.$ARCH CPU architecture, such as I386, X86_64, etc.
These YUM variables have different values based on the version architecture of the current system, which facilitates the selection of software packages suitable for the current system during the YUM upgrade
GnuPG (REFERRED to as GPG) is one of the most popular and useful encryption tools. The GNU Privacy Guard.
Yum addresses dependency principles
YUM can solve the dependency problem by automatically downloading packages.
Yum is based on the C/S architecture. C refers to the client, S refers to the server, such as FTP, HTTP,file and other protocols.
On why YUM solves dependencies: All YUM sources have RepoData, which is an XML file with instructions on what packages are required.
For example, mysql-community-client, mysql-community-common, mysql-community-libs and other dependencies are required to install mysql-community-server.
Yum Group commands
Yum group related commands can install all necessary software for a group at once. This is useful for situations where you want to implement or install a service, saving you the trouble of installing it one by one.
For example, to install the Development Libraries on RHEL/CentOS, run the following commands:
# yum install gcc
# yum install glibc
# yum install make
Copy the code
or
# yum install gcc glibc make
Copy the code
And there may be leakage, less safe situation.
With yum GroupInstall, however, you can install all the required packages with a single command to install a set of packages for a particular task.
Yum grouplist can list all of the available groups, or yum grouplist | more page view.
Yum Grouplist classifies groups as shown below:
View the Development related groups, yum grouplist | grep Development:
# yum grouplist | grep Development -i
Development and Creative Workstation
Development tools
Copy the code
yum groupinfo
View details about a group.
View information about the Development Tools group:
# yum groupinfo Development tools
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Group: Development tools
Group-Id: development
Description: A basic development environment.
Mandatory Packages:
+autoconf
......
+rpm-build
+rpm-sign
Default Packages:
+byacc
......
+swig
+systemtap
Optional Packages:
ElectricFence
...
trac-webadmin
translate-toolkit
Warning: group/environment tools does not exist.
Copy the code
Install all development libraries using groups:
yum groupinstall "Development Tools"
Copy the code
Quotation marks are recommended.
For example, if you want to install an email Server, you can also use a group to install an email Server:
yum groupinstall "E-mail server"
Copy the code
Yum groupinstall “Security Tools”
Yum supports the following group commands:
- yum grouplist
- yum groupinfo
- yum groupinstall
- yum groupremove
- yum groupupdate
Configure the local YUM source
The YUM repository source can also be specified as a local ISO disc file or an image file. The installation can be accessed without an Internet connection.
RPM Packages are commonly used in Linux installation image files (ISO files). Use compressed files to open the system installation image files. You can find almost all commonly used RPM Packages in the Packages subdirectory. Full version of CentOS ISO file
Here’s how to use the system installation image as the local YUM source.
Repo = centos-media. Repo = centos-media. Repo = centos-media. Repo = centos-media.
- Insert the CentOS installation CD-ROM and mount the Cd-Rom to the specified location.
# mkdir /mnt/cdrom
Create a cdrom directory as a mount point for the CD
# mount /dev/cdrom /mnt/cdrom/
mount: block device/dev/srO is write-protected, mounting read-only
Mount CD to/MNT /cdrom
Copy the code
- Modify the configuration file centos-media. repo of the CD yum source
# vim CentOS-Media.repo
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom
Address for your own CD mount address
#file:///media/cdrom/
#file:///media/cdrecorder/
# comment the nonexistent addresses of these two
gpgcheck=1
enabled=1
# change enabled=0 to enabled=1 to enable the yum source configuration file
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Copy the code
-
Disable other network repo files (or simply change the suffix and extension of other repo files, yum only recognizes. Repo as repository source configuration files)
-
Reloading YUM, cleaning and rebuilding the cache is recommended after modifying or adding repo software source configuration files [not required]
yum clean all
yum makecache
Copy the code
aboutyum list
andyum list installed
The command
These are used to list all packages contained in the YUM repository, and list all packages installed.
Specify package full name
Yum does not support wildcards, but you can specify the full name of the package after the yum list and yum list installed commands, which are the same for installed packages:
# yum list installed mysql-community-server-8.0.26-1.el7.x86_64 # yum list installed mysql-community-server-8.0.26-1
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
mysql-community-server.x86_64 8.0.26-1.el7 @mysql80-community
# mysql - community - yum list server - 8.0.26-1. El7. X86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
mysql-community-server.x86_64 8.0.26-1.el7 @mysql80-community
Copy the code
yum list
,yum list installed
Lists all installable and installed packages
-
Yum List — Lists all installable packages, both installed and uninstalled.
-
Yum List Installed — Lists all installed packages.
Run the two commands directly.
Using the grep command
# yum list installed | grep mysqlX86_64 8.0.26-1. el7@mysql80-community mysql-community-client-plugins.x86_64 8.0.26-1. El7 @mysql80-community mysql-community-common.x86_64 8.0.26-1.el7 @mysql80-community mysql-community-libs.x86_64 8.0.26-1. el7@mysql80-community mysql-community-server.x86_64 8.0.26-1. el7@mysql80-community mysql80-community-release.noarch el7-3 installedCopy the code
Below, you can see, yum list | grep mysql contains yum list installed | grep mysql installed packages:
Yum list keyword* use the wildcard
List software names starting with PAM:
# yum list pam*Loaded plugins: fastestmirror, Langpacks Loading mirror speeds from cached hostfile Installed Packages pam.i686 1.1.8-22.el7@OS pam.x86_64 1.1.8-22. El7 @ OS Available Packages. PAM i686 1.1.8-23. El7 OS. PAM x86_64 1.1.8-23. El7 OS PAM - devel. I686 1.1.8-23. El7 OS Pam-devel. X86_64 1.1.8-23.el7 OS PAM-kwallet. X86_64 5.5.2-1. El7 epel pam_2FA.x86_64 1.0-1 Pam_afs_ssession. X86_64 2.8-5.el7 epel pam_krb5.i686 2.4.8-6.el7 OS pam_krb5.x86_64 2.4.8-6.el7 OS pam_mpi.x86_64 El7 epel pam_mount.x86_64 2.16-5.el7 epel pam_oath. X86_64 2.6.2-1.el7 epel pam_pkcs11.i686 0.62-30.el7 OS X86_64 0.6.2-30.el7 OS pam_radius.x86_64 1.4.0-4.el7 epel pam_script.x86_64 1.1.8-1.el7 epel pam_snapper.i686 El7 OS pam_ssh.x86_64 2.8-4.el7 OS pam_ssh.x86_64 2.3-2.el7 epel pam_ssh_agent_auth.i686 0.10.3-2.21.el7 OS pam_ssh_agent_auth.x86_64 0.10.3-2.21.el7 OS pam_ssh_user_auth.x86_64 1.0-1.el7 epel pam_url. X86_64 1:0.3.3-4.el7 X86_64 1.1.3-1.el7 epel pam_yubico. X86_64 2.26-1. El7 epel pamtester.x86_64 0.1.2-4.el7 epel#
Copy the code
Combine the more and less commands
The content displayed by yum List and Yum List Installed is too long to be piped to “more” or “less” commands and paged for viewing.
yum list installed | more
yum list installed | less
Copy the code
Installation and uninstallation
Example of installing a package
Install pam-devel: yum install pam-devel
# yum install pam-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package pam-devel.x86_64 0:1.1.8-23.el7 will be installed
--> Processing Dependency: pam(x86-64) = 1.1.8-23.el7 forpackage: Pam-vel -1.1.8-23.el7.x86_64 --> Running Transaction Check --> Package Pam.i686 0:1.1.8-22.el7 will be updated --> I686 0:1.1.8-23.el7 will be an update --> Package pam.x86_64 0:1.1.8-22.el7 will be an update --> Package Pam.x86_64 0:1.1.8-23. El7 will be an update --> Finished Dependency Resolution Dependencies Resolved =========================================================================== Package Arch Version Repository Size =========================================================================== Installing: Pam-devel x86_64 1.1.8-23.el7 OS 185 k Updatingfordependencies: PAM I686 1.1.8-23. El7 OS 720 K PAM X86_64 1.1.8-23. El7 OS 721 K Transaction Summary =========================================================================== Install 1 Package Upgrade ( 2 Dependent Packages) Total Download Size: 1.6m Is this OK [Y/D /N]: Y Downloading packages: No Presto metadata availableforOS (1/3) : PAM - 1.1.8-23. El7. I686. RPM | 720 kB 00:00 (2/3) : PAM - 1.1.8-23. El7. X86_64. RPM | 721 kB 00:00 (3/3) : PAM - devel - 1.1.8-23. El7. X86_64. RPM | 185 kB 00:00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Total 1.8 MB/s | 1.6 MB 00:00 Running transaction check Running transactiontest
Transaction testSucceeded Running transaction Updating: PAM-1.1.8-23.el7.x86_64 1/5 Installing: Updating: pam-vel - 1.8-23.el7.x86_64 2/5 Updating: pam-1.1.8-23.el7.i686 3/5 Cleanup: pam-1.1.8-22.el7 4/5 Cleanup: Updating: pam-1.1.8-23.el7.i686 3/5 Cleanup: pam-1.1.8-22.el7 4/5 PAM - 1.1.8-22. Verifying el7 5/5: PAM - 1.1.8-23. El7. Verifying i686 1/5: PAM - 1.1.8-23. El7. Verifying x86_64 2/5: Pam-vel - 1.8-23.el7.x86_64 3/5 Verifying: PAM-vel - 1.8-22.el7.i686 4/5 Verifying: pam-vel - 1.8-23.el7.x86_64 3/5 Verifying: PAM-vel - 1.8-22.el7.i686 4/5 Verifying: Pam-1.8-22.el7.x86_64 5/5 Installed: PAM-vel. X86_64 0:1.1.8-23.el7 Dependency Updated: pam-vel. X86_64 0:1.1.8-23.el7 Dependency Updated: pam-vel. Pam.i686 0:1.1.8-23.el7 pam.x86_64 0:1.1.8-23.el7 Complete!#
Copy the code
The entire installation process can be seen:
Considerations Dependencies: Start Resolving Dependencies Dependencies Resolved Transaction Summary: Transaction Summary of the installation; Install 1 Package Upgrade (2 Dependent packages) Install 1 Package Upgrade (2 Dependent packages) Finally, there are the installed packages and updated dependencies, and Complete! To complete.
Example of uninstalling packages
Yum Remove does not remove dependencies that were installed with the package!
Yum remove pam-devel yum remove pam-devel
# yum remove pam-develLoaded plugins: fastestmirror, Langpacks Resolving Dependencies --> Running Transaction Check --> Package pam-vel. X86_64 0:1.1.8-23.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved =========================================================================== Package Arch Version Repository Size =========================================================================== Removing: Pam-devel x86_64 1.1.8-23.el7@OS 528 K Transaction Summary =========================================================================== Remove 1 Package Installed size: 528 k Is this ok [y/N]: y Downloading packages: Running transaction check Running transactiontest
Transaction testSucceeded Running transaction Erasing: PAM-vel -1.1.8-23.el7.x86_64 1/1 Verifying: Pam-vel - 1.8-23.el7.x86_64 1/1 Removed: Pam-Vel. X86_64 0:1.1.8-23.el7 Complete!#
Copy the code
The whole unloading process:
Considerations Dependencies: Start Resolving Dependencies Dependencies Resolved Transaction Summary: Uninstalled Transaction Summary; Remove 1 Package: uninstalls a Package; Finally, the package is uninstalled.
Yum search is introduced
Yum Search is used to find packages. By default, it looks for the full name of the package and the package that contains the lookup name in the summary.
Mysql > select * from mysql;
# yum search mysql
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
========================================================= N/S matched: mysql ==========================================================
MySQL-python.x86_64 : An interface to MySQL
MySQL-zrm.noarch : MySQL backup manager
akonadi-mysql.x86_64 : Akonadi MySQL backend support
anope-mysql.x86_64 : MariaDB/MySQL modules for Anope IRC services
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
collectd-mysql.x86_64 : MySQL plugin for collectd
' ' ' ' ' 'Innotop. Noarch: A MySQLand InnoDB monitor program
mariadb.x86_64 : A community developed branch of MySQL
mariadb-devel.i686 : Files for development of MariaDB/MySQL applications
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients
mylvmbackup.noarch : Utility for creating MySQL backups via LVM snapshots
mysql-community-server.x86_64 : A very fast and reliable SQL database server
mysql-mmm-agent.noarch : MMM Database Server Agent Daemon and Libraries
mysql-mmm-monitor.noarch : MMM Monitor Server Daemon and Libraries
mysql-mmm-tools.noarch : MMM Control Scripts and Libraries
mytop.noarch : A top clone for MySQL
percona-xtrabackup.x86_64 : Online backup for InnoDB/XtraDB in MySQL, Percona Server and MariaDB
php-phpmyadmin-sql-parser.noarch : A validating SQL lexer and parser with a focus on MySQL dialect
php-udan11-sql-parser.noarch : A validating SQL lexer and parser with a focus on MySQL dialect
phpMyAdmin.noarch : Handle the administration of MySQL over the World Wide Web
zabbix30-dbfiles-mysql.noarch : Zabbix database schemas, images, data and patches
zabbix40-dbfiles-mysql.noarch : Zabbix database schemas, images, data and patches
Name and summary matches only, use "search all" for everything.
Copy the code
reference
Main reference from Linux yum command, repo file details, Linux yum is what, yum source configuration (network yum source and local yum source) and some information on the Internet