Linux yum Command
yum (Yellow dog Updater, Modified) is a shell-frontend package manager for Fedora, RedHat, and SUSE.
Based on RPM package management, it can automatically download and install RPM packages from specified servers, handle dependencies, and install all required packages at once without the need for repeated downloads and installations.
yum provides commands for finding, installing, and deleting individual, groups, or all software packages, with concise and easy-to-remember commands.
yum Syntax
yum [options] [command] [package ...]
options: Optional, including -h (help), -y (assume "yes" for all prompts), -q (do not show installation progress), etc.
command: The operation to be performed.
package: The name of the package to be installed.
Common yum Commands
List all available updates:
yum check-update
Update all software:
yum update
Install a specific package:
yum install <package_name>
Update a specific package:
yum update <package_name>
List all installable packages:
yum list
Remove a package:
yum remove <package_name>
Search for a package:
yum search <keyword>
Clear cache commands:
yum clean packages
: Clear packages in the cache directoryyum clean headers
: Clear headers in the cache directoryyum clean oldheaders
: Clear old headers in the cache directoryyum clean, yum clean all (= yum clean packages; yum clean oldheaders)
: Clear packages and old headers in the cache directory
Example 1
Install pam-devel
[root@www ~]# yum install pam-devel
Setting up Install Process
Parsing package install arguments
Resolving Dependencies <== Check dependency issues first
--> Running transaction check
---> Package pam-devel.i386 0:0.99.6.2-4.el5 set to be updated
--> Processing Dependency: pam = 0.99.6.2-4.el5 for package: pam-devel
--> Running transaction check
---> Package pam.i386 0:0.99.6.2-4.el5 set to be updated
filelists.xml.gz 100% |=========================| 1.6 MB 00:05
filelists.xml.gz 100% |=========================| 138 kB 00:00
-> Finished Dependency Resolution
……(omitted)
Example 2
Remove pam-devel
[root@www ~]# yum remove pam-devel
Setting up Remove Process
Resolving Dependencies <== Resolve dependency issues first
--> Running transaction check
---> Package pam-devel.i386 0:0.99.6.2-4.el5 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Removing:
pam-devel i386 0.99.6.2-4.el5 installed 495 k
Transaction Summary
Install 0 Package(s) Update 0 Package(s) Remove 1 Package(s) <== Fortunately, there are no dependency issues, simply removing one software
Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Erasing : pam-devel ######################### [1/1]
Removed: pam-devel.i386 0:0.99.6.2-4.el5 Complete!
### Example 3
Using the yum feature, find out what software names start with pam?
[root@www ~]# yum list pam* Installed Packages pam.i386 0.99.6.2-3.27.el5 installed pam_ccreds.i386 3-5 installed pam_krb5.i386 2.2.14-1 installed pam_passwdqc.i386 1.0.2-1.2.2 installed pam_pkcs11.i386 0.5.3-23 installed pam_smb.i386 1.1.7-7.2.1 installed Available Packages <== These are 'upgradable' or 'not installed' pam.i386 0.99.6.2-4.el5 base pam-devel.i386 0.99.6.2-4.el5 base pam_krb5.i386 2.2.14-10 base
---
## Domestic yum Sources
NetEase (163) yum source is one of the best yum sources in China, with both speed and software versions being very good.
Setting the yum source to 163 yum can enhance the speed of software package installation and updates, and also avoid common issues where certain software versions cannot be found.
### Installation Steps
First, backup /etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
Download the corresponding version repo file, and place it in /etc/yum.repos.d/ (please make appropriate backups before operation)
-[CentOS5](http://mirrors.163.com/.help/CentOS5-Base-163.repo): http://mirrors.163.com/.help/CentOS5-Base-163.repo
-[CentOS6](http://mirrors.163.com/.help/CentOS6-Base-163.repo): http://mirrors.163.com/.help/CentOS6-Base-163.repo
-[CentOS7](http://mirrors.163.com/.help/CentOS7-Base-163.repo): http://mirrors.163.com/.help/CentOS7-Base-163.repo
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo mv CentOS6-Base-163.repo CentOS-Base.repo
Generate cache with the following commands
yum clean all yum makecache ```
In addition to NetEase, there are other good yum sources in China, such as the University of Science and Technology of China and Sohu. The installation method for USTC's yum repository can be found at: https://lug.ustc.edu.cn/wiki/mirrors/help/centos
The installation method for Sohu's yum repository can be found at: http://mirrors.sohu.com/help/centos.html