Linux yum command
yum is the default package manager for CentOS 5/6/7 and RHEL 5/6/7. Its dependency resolution performance is poor, and it can easily stall in complex dependency scenarios. Official maintenance has now been discontinued.
Starting from CentOS 8, RHEL 8, and later versions, the system defaults to the successor tooldnf; dnf is backward compatible with the vast majority of yum commands, with basically the same usage habits.
yum (Yellow dog Updater, Modified) is a Shell front-end package manager in Fedora, RedHat, and SUSE.
For CentOS 8, RHEL 8, and later versions, please use the dnf command:https://www.example.com/linux/linux-comm-dnf.html
Based on RPM package management, it can automatically download and install RPM packages from a specified server, automatically handle dependency relationships, and install all dependent packages at once, without the tedious process of downloading and installing one by one.
yum provides commands to find, install, and delete a single package, a group of packages, or even all packages, and the commands are concise and easy to remember.
yum syntax
yum [options] [command] [package ...]
- options:Optional. Options include -h (help), -y (when prompted during installation, answer "yes" to all), -q (do not display the installation process), and so on.
- command:The operation to be performed.
- package:The name of the package to install.
Common yum commands
-
1. Command to list all updatable software:yum check-update
-
2. Command to update all software:yum update
-
3. Command to install only the specified software:yum install <package_name>
-
4. Command to update only the specified software:yum update <package_name>
-
5. Command to list all installable software:yum list
-
6. Command to remove software packages:yum remove <package_name>
-
7. Command to find software packages:yum search <keyword>
-
8. Command to clear the cache:
- yum clean packages: Clear the software packages in the cache directory
- yum clean headers: Clear the headers in the cache directory
- yum clean oldheaders: Clear the old headers in the cache directory
- yum clean, yum clean all (= yum clean packages; yum clean oldheaders): Clear the software 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 <==先检查软件的属性相依问题 --> 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 ……(省略)
Example 2
Remove pam-devel
[root@www ~]# yum remove pam-devel Setting up Remove Process Resolving Dependencies <==同样的,先解决属性相依的问题 --> 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) <==还好,并没有属性相依的问题,单纯移除一个软件 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
Use yum's functionality to find out which 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 <==底下则是『可升级』的或『未安装』的 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 mirrors
NetEase (163) yum mirror is one of the better yum mirrors in China; both speed and software versions are very good.
Setting the yum mirror to 163 yum can improve the speed of software package installation and updates, while avoiding the issue of some common software versions being unavailable.
Installation steps
First, back up /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 repo file for the corresponding version and place it in /etc/yum.repos.d/ (make appropriate backups before operating)
- CentOS5 :http://mirrors.163.com/.help/CentOS5-Base-163.repo
- CentOS6 :http://mirrors.163.com/.help/CentOS6-Base-163.repo
- CentOS7 :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
Run the following command to generate the cache
yum clean all yum makecache
Besides NetEase, there are other good domestic yum mirrors, such as USTC and Sohu.
For USTC's yum mirror, see the installation method:https://lug.ustc.edu.cn/wiki/mirrors/help/centos
For Sohu's yum mirror installation method, see:http://mirrors.sohu.com/help/centos.html
Alibaba Cloud's mirror:https://developer.aliyun.com/mirror/centos
Other extensions