Basic usage and examples of yum under Linux (centos8)

yum command

Yum (full name: Yellow dog Updater, Modified) is a Shell front-end package manager in Fedora, RedHat and CentOS. Based on RPM package management, it can automatically download and install RPM packages from the specified server, automatically handle dependencies, and install all dependent software packages at one time without cumbersome downloading and installation at one time.


yum syntax

1 yum [options] [command] [package ...]
  • Options: optional. The options include - h (help), - y (select "yes" when prompted by the installation process), - q (do not display the installation process), etc.
  • command: the operation to be performed.
  • The object of the package operation.



-h: Display help information;
-y: Answer "yes" to all questions;
-c: Specify the configuration file;
-q: Quiet mode;
-v: Detailed mode;
-d: Set the commissioning level (0-10);
-e: Set the error level (0-10);
-R: Set the maximum waiting time for yum to process a command;
-C: Run completely from the cache without downloading or updating any header files.


#Regular orders
install: install rpm Software package; update: to update rpm Software package; check-update: Check for updates available rpm Software package; remove: Delete the specified rpm Software package; list: Display the information of the software package; search: Check the information of the software package; info: Displays the specified rpm Description and summary information of the software package; clean: clear yum Expired cache; shell: get into yum of shell Prompt; resolvedep: display rpm Dependency of software package; localinstall: Install local rpm Software package; localupdate: Show local rpm Update the software package; deplist: display rpm All dependencies of the package. alias List or create command aliases autoremove Remove all unneeded packages that were originally installed because of dependencies check Find problems in the package database check-update Check for software package upgrades clean Delete cached data deplist Lists the dependencies of software packages and the sources that provide them distro-sync Synchronize installed packages to the latest available version downgrade Degraded package group Display or use group information help Displays a helpful usage message history Display or use transaction history info Displays detailed information about a package or package group install Install one or more software packages into the system list Lists a package or group of packages makecache Create metadata cache mark Mark or unmark packages installed by users in installed packages. module Interact with the module. provides Find packages that provide the specified content reinstall Reload a bag remove Remove one or more software packages from the system repolist Displays the configured software warehouse repoquery Search for packages that match keywords repository-packages Run the command on all packages in the specified repository search Searches the package details for the specified string shell Run interactive DNF terminal swap Run interactive DNF Terminal to remove or install spec Description file updateinfo Displays reference suggestions for the package upgrade Upgrade one or more software packages in the system upgrade-minimal Upgrade, but only the "latest" package has fixed problems that may affect your system List of plug-in commands: builddep Install build dependencies for package or spec file changelog View the change log data of the software package config-manager Administration dnf Configuration options and software warehouse copr And Copr Warehouse interaction debug-dump Dump installed RPM Package information to file debug-restore Recover the software package record in the debug dump file debuginfo-install Install and debug information package download Download the package to the current directory needs-restarting Determine whether the upgraded binary needs to be restarted playground And Playground Warehouse interaction. repoclosure Displays a list of unresolved dependencies in the warehouse repodiff List the differences between the two sets of warehouses repograph Output the complete software package dependency diagram in the form of dotted line diagram repomanage Administration RPM Package directory reposync Download all software packages in the remote warehouse




yum install # all
 yum install package1 # installs the specified package1
 yum groupinsall group1 # setup group1

Update and upgrade

Update # all using Yum or up2date
 Update package1 using Yum or up2date # to update the specified package1
 Yum check update # checks for updatable programs
 Upgrade package package1 using Yum or up2date # to upgrade the specified package package1
 yum groupupdate group1 # upgrade program group1

Find and display

yum info package1 # displays the installation package information
 yum list # displays all installed and installable packages
 yum list package1 # displays the installation of the specified package
 yum groupinfo group1 # displays program group1 information. yum search string searches for installation packages by keyword string

Delete program

yum remove |  Erase package1 # delete package1
 yum groupremove group1 # deletes the program group1
 Yum / up2date deplist package1 # to view program package1 dependencies

Clear cache

yum clean packages # clears the packages in the cache directory
 yum clean headers # clears headers in the cache directory
 Yum clean oldheads # clears old headers from the cache directory
yum clean all # clears all cache directories


Linux configuration yum source



Domestic yum source:






China University of science and technology:


View yum source configuration

cat /etc/yum.repos.d/CentOS-Base.repo









[base]           #Warehouse name
name=            #Warehouse description
mirrorlist=      #Warehouse image path
baseurl=         #Warehouse url path
enabled=         #Whether the warehouse is enabled. 1 means enabled and 0 means closed
gpgcheck=1       #Key detection: 1 means on, 0 means off
gpgkey=          #Check the address of the key. If it is not checked, this can be left blank








1. yum source configuration (Network):

1.1 back up the original yum source first:

[root@alliancehacker ~]# mkdir -p /root/back
[root@alliancehacker ~]# mv /etc/yum.repos.d/CentOS-Base.repo  /root/back/CentOS-Base.repo.back

1.2 download the new yum source (Alibaba):

// Because this is CentOS 8, the source chose centos-8 repo
[root@alliancehacker ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo



1.3 clear the original yum cache:

[root@localhost ~]# yum clean all

1.4 generate new cache:

[root@localhost ~]# yum makecache

1.5 add multiple network sources:

#stay /etc/yum.repo.d There are several folders in, and each folder is a source configuration file.#For example:
#(1) Local Repo (local source, name optional)
#(2) 163 Repo (source of 163)
#It should be noted here that you need to go to the base URL Here, find the directory of your corresponding redhat version, and then click os and x86_64 (usually), and then replace the baseurl above with the URL displayed on your address bar. Save and exit.


1.6 order supplement

I hope the following information can answer your question:
1. Query current repo (all, enabled, disabled)

yum repolist [all|enabled|disabled]


Install the software and specify the repo you do not want to use

yum –-disablerepo=repository-name install nagios


Install the software from the repo set to disabled (enabled=0)

yum --enablerepo=epel install nagios


In a repo setting, specify the package name you want to exclude



If there are multiple versions of one software in multiple repo s, you can specify the version during installation

yum install httpd-2.4.6-6



2. yum source configuration (local):

2.1 downloading ISO files

Download the full version of CentOS iso file from CentOS's official website and upload it to the Linux file system, such as / opt/tools /.

2.2 create a mount directory for ISO

1 mkdir /mnt/vcdrom

2.3 mount ISO files to the mount directory

mount -o loop -t iso9660 /opt/tools/CentOS-7-x86_64-bin-DVD1.iso /mnt/vcdrom


2.4 remove or back up the original yum source CentOS base Repo file

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.back


2.5 configuring CentOS media Repo file

[root@localhost ~]# cat /etc/yum.repos.d/CentOS-Media.repo 
name=CentOS-$releasever - Media
baseurl=file:///MNT / vcrom / # change the baseurl to the mounting directory of the DVD
gpgcheck=0                            #Turn off key detection
enabled=1                             #Enable warehouse


2.6 clear the original yum cache:

[root@localhost ~]# yum clean all


2.7 generate new cache:

[root@localhost ~]# yum makecache


2.8 write script and automatically mount image after startup

[root@localhost ~]#vim /opt/shell/
mount -o loop -t iso9660 /opt/tools/CentOS-6.7-x86_64-bin-DVD1.iso /mnt/vcdrom


2.9 modify script permissions:

[root@localhost ~]#chmod 777 /opt/shell/

2.10 modify / etc / RC Local configuration file, add / opt / shell / mymount. At the last line of the file sh

[root@localhost ~]#vim /etc/rc.local

2.11 server restart test:

[root@localhost ~]# reboot



Example 1: install php7 using yum or up2date


Reference: php7 3 install @ centos7
Find your own version on this website and replace it. Some sources may become invalid. Find the available ones by yourself at that time
#Add several sources, otherwise an error will be reported
#The yum source address of php higher version has two parts, one of which is EPEL release and the other is from webtatic. If you skip EPEL release, when installing webtatic
rpm -Uvh
rpm -Uvh




Install the extensions you want

yum --enablerepo=remi install php73-php php73-php-pear php73-php-bcmath php73-php-pecl-jsond-devel php73-php-mysqlnd php73-php-gd php73-php-common php73-php-fpm php73-php-intl php73-php-cli php73-php php73-php-xml php73-php-opcache php73-php-pecl-apcu php73-php-pdo php73-php-gmp php73-php-process php73-php-pecl-imagick php73-php-devel php73-php-mbstring php73-php-zip php73-php-ldap php73-php-imap php73-php-pecl-mcrypt


Run and view the version, restart the command, add automatic startup, and link php files

# The current PHP memory limit is below the recommended value of 512MB.
vi /etc/opt/remi/php73/php.ini
memory_limit = 512M

#If you are running nginx instead of apache, modify
vi /etc/opt/remi/php73/php-fpm.d/www.conf
user = apache
group = apache
# Replace the values with
user = nginx
group = nginx


Uninstall all php7 three


yum remove php73-php*

Posted by rigy73 on Mon, 23 May 2022 03:45:47 +0300