Basic usage and examples of yum under Liunx (centos8) (recommended)

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 a designated server, automatically handle dependencies, and install all dependent software packages at one time, without the need for tedious download and installation again and again.

yum syntax

Object of package operation.

Option -h: display help information; -y: answer "yes" to all questions; -c: specify the configuration file; -q: quiet mode; -v: detailed mode; -d: set the debugging 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.

parameter

# Regular command
install: install the rpm software package;
update: update the rpm software package;
check-update: Check if there is an update rpm package available;
remove: delete the specified rpm software package;
list: display information about the software package;
search: Check the information of the software package;
info: Display the description and summary information of the specified rpm software package;
clean: clean up the expired cache of yum;
shell: Enter yum's shell prompt;
resolvedep: display the dependencies of rpm packages;
localinstall: install the local rpm software package;
localupdate: display the local rpm package to be updated;
deplist: Display all dependencies of the rpm package.

alias list or create command alias
autoremove removes all unnecessary packages that were originally installed due to dependencies
check Look for problems in the package database
check-update check if there is a package upgrade
clean delete cached data
deplist lists the dependencies of packages and the sources that provide these packages
distro-sync synchronizes the installed packages to the latest available version
downgrade downgrade package
group display or use group information
help displays a helpful usage information
history display or use transaction history
info displays detailed information about a package or package group
install installs one or more packages to the system
list lists one or a group of packages
makecache creates metadata cache
mark Mark or unmark the software package installed by the user in the installed software package.
module interacts with the module.
provides Find packages that provide specified content
reinstall reinstall a package
remove Remove one or more packages from the system
repolist displays the configured software repositories
repoquery searches for packages matching keywords
repository-packages run commands on all packages in the specified warehouse
search Search for the specified string in the package details
shell running interactive DNF terminal
swap runs an interactive DNF terminal to delete or install spec description files
updateinfo shows the recommendations of the package
upgrade upgrade one or more packages in the system
upgrade-Minimal upgrade, but only the "latest" software packages have fixed issues that may affect your system

List of plugin commands:

builddep Install build dependencies forpackage or spec file
changelog View the change log data of the package
config-manager manages dnf configuration options and software repositories
Copr interacts with Copr warehouse
debug-dump dump installed RPM package information to file
debug-restore restores the package records in the dump file for debugging
debuginfo-install Installation and debugging information package
download Download the package to the current directory
needs-restarting Determine whether the upgraded binary file needs to be restarted
The playground interacts with the Playground warehouse.
repoclosure displays a list of unresolved dependencies in the repository
repodiff lists the differences in the two sets of warehouses
repograph outputs a complete package dependency graph in a dot and line graph
repomanage manages RPM package directory
reposync downloads all packages in the remote warehouse

installation

yum install    #Install all
yum install package1  #Install the specified installation package package1
yum groupinsall group1 #Installer group group1

Update and upgrade

yum update    #Update all
yum update package1  #Update the specified package package1
yum check-update   #Check for updateable programs
yum upgrade package1  #Upgrade the specified package package1
yum groupupdate group1 #Upgrade program group group1

Find and display

yum info package1  #Display installation package information package1
yum list    #Show all installed and available packages
yum list package1  #Display the installation status of the specified package package1
yum groupinfo group1 #Display program group group1 information yum search string Find the installation package according to the keyword string

Delete program

yum remove | erase package1 #Delete package package1
yum groupremove group1    #Delete program group group1
yum deplist package1    #View program package1 dependencies

clear cache

yum clean packages  #Clear the package in the cache directory
yum clean headers  #Clear headers in the cache directory
yum clean oldheaders  #Clear old headers in the cache directory
yum clean all  #Clear all cache directories

Linux configuration yum source

Domestic Yum source:

Ali: http://mirrors.aliyun.com

NetEase: http://mirrors.163.com

University of Science and Technology of China: http://mirrors.ustc.edu.cn/

View yum source configuration

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

[ base] #Warehouse name name= #Warehouse description mirrorlist= #Warehouse mirror path baseurl= #Warehouse url path enabled= #Whether the warehouse is enabled, 1 means enabled, 0 means disabled gpgcheck=1 #Key check, 1 means open, 0 means Turn off gpgkey= #Check the address of the key, if the above is not checked, this can be omitted

1、 Yum source configuration (network):

1.1 First back up the original yum source:

[ 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 (Ali):

//Because I am centos8,The source chose Centos-8.repo[root@alliancehacker ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

1.3 Clear the original Yum cache:

[ root@localhost ~]# yum clean all

1.4 Generate a new cache:

[ root@localhost ~]# yum makecache

1.5 Add multiple network sources:

# in/etc/yum.repo.There are several folders in d, and each folder is a source configuration file.#E.g:
# (1) local.repo (local source, the name is arbitrary)
[ local]
name=local
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
# (Two) 163.repo(Source of 163)[163]
name=163
baseurl=http://mirrors.163.com/centos/7.5.1804/os/x86_64/
gpgcheck=0
enabled=1
# It should be noted here that, for baseurl, you have to go to http://mirrors.163.com/Here on centos, find the directory of your corresponding redhat version, then click os, then x86_64 (generally available),Then replace the baseurl above with the URL displayed on your address bar, save and exit.

1.6 Command supplement

Hope the following information can answer your question:

  1. Query the current repo (all, enabled, disabled)

yum repolist [all|enabled|disabled]

Install the software and specify the repo you don’t 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 certain repo setting, specify the name of the package you want to exclude

exclude=nagios

If there are multiple versions of a certain software in multiple repo, you can specify the version when installing

yum install httpd-2.4.6-6

**2、 Yum source configuration (local): **

2.1 Download the ISO file

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

2.2 Create a mount directory for the ISO

mkdir /mnt/vcdrom

2.3 Mount the ISO file to the mount directory

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

2.4 Remove or backup 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 Configure Centos-Media.repo file

[ root@localhost ~]# cat /etc/yum.repos.d/CentOS-Media.repo 
[ c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/vcdrom/   #Modify baseurl to the DVD mount directory
gpgcheck=0       #Turn off key detection
enabled=1        #Enable warehouse
# gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

2.6 Clear the original Yum cache:

[ root@localhost ~]# yum clean all

2.7 Generate a new cache:

[ root@localhost ~]# yum makecache

2.8 Write a script to automatically mount the image

[ root@localhost ~]#vim /opt/shell/mymount.sh
#! /bin/bash
#
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/mymount.sh

2.10 Modify the /etc/rc.local configuration file and add /opt/shell/mymount.sh to the last line of the file

[ root@localhost ~]#vim /etc/rc.local
/opt/shell/mymount.sh

2.11 Restart the server test:

[ root@localhost ~]# reboot

Example 1: Use yum to install php7

Reference: php7.3 install @centos7

PHP7.3 yum install@Centos 7

https://dl.fedoraproject.org/pub/epel/ http://rpms.remirepo.net/enterprise You can find your own version on this website, and then replace it. Some sources may become invalid. Find what is available for yourself

# Add a few sources, otherwise an error will be reported
# The yum source address of the high version of php has two parts, one of which is epel-release, another part comes from webtatic. If skip epel-For release, when installing webtatic
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Install the extension 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 check the version, restart the command, add autostart, link the php file

# 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.3

yum remove php73-php*

to sum up

The above is the basic usage and examples of yum under Liunx (centos8) introduced by the editor, I hope to help you!

Recommended Posts

Basic usage and examples of yum under Liunx (centos8) (recommended)
Installation and configuration of redis under centos7
Install svn and configuration through yum under CentOS
Installation and configuration of rsync server under CentOS 6.5
Installation and cracking of confluence6.3 operation records under Centos
Installation and cracking of Jira7 operation records under Centos
Environment configuration of JDK, mysql and tomcat under Centos7
Installation and usage instructions of rz/sz command under ubuntu
Centos 6.10 reinstall python and yum
Deployment of vulnerability scanning and analysis software Nessus under CentOS
CentOS7 yum install and start mysql
Install and configure keepalived under CentOS 5.9
Analysis of usage examples of Python yield
CentOS Yum compile and install MySQL 5.6
Compile and install LAMP under Centos 5.2
CentOS 8 install Git and basic configuration
Use Nginx and u under CentOS
Installation under centos6.9 of jenkins learning
CentOS7 installation and maintenance of Gitlab
Upgrade OpenSSL and OpenSSH under CentOS7
Deploy and optimize Tomcat under Centos
Detailed examples of Centos6 network configuration
CentOS7 yum install and start mysql
Java-JDK installation and configuration under CentOS
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
Install Python3 and Py under CentOS7
Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
Erlang 20.2 installation and deployment under CentOS 7
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
A brief introduction to yum source configuration and nmcli commands under CentOS8
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Centos7 installation and deployment of gitlab server
Install docker on ubuntu and basic usage
Centos 8.1.1911 solves the problem of yum reinstallation
Zabbix installation and deployment and localization under CentOS
Jenkins installation and deployment tutorial under CentOS 7
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
The fourth installment of Zabbix under CentOs7
KVM installation and preliminary use under CentOS 7.2
Compile and install nodejs and yum in Centos8
Construction of Zabbix monitoring platform under CentOS7
Centos7 installation and deployment of Airflow detailed
Install Docker CE in yum under CentOS 7