English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux yum Command

yum (Yellow dog Updater, Modified) is a package manager frontend in Shell for Fedora, RedHat, and SUSE.

Based on RPM package management, yum can automatically download RPM packages from specified servers and install them, and can automatically handle dependency relationships and install all dependent software packages at once, without the need for cumbersome repeated downloads and installations.

yum provides commands for searching, installing, and deleting individual, a group, or even all software packages, and the commands are concise and easy to remember.

yum syntax

yum [options] [command] [package ...]
  • options:Optional, options include-h (help),-y (when the installation process prompts to select all as "yes"),-q (do not display the installation process) etc.

  • command:The operation to be performed.

  • package:The name of the installed package.

Common yum commands

  • 1. List all available update software packages command: yum check-update

  • 2. Update all software command: yum update

  • 3. Install specified software only command: yum install <package_name>

  • 4. Update specified software only command: yum update <package_name>

  • 5. List all available software packages command: yum list

  • 6. Delete package command: yum remove <package_name>

  • 7. Find package command: yum search <keyword>

  • 8. Clear cache command:

    • yum clean packages: Clear the software packages under the cache directory

    • yum clean headers: Clear the headers under the cache directory

    • yum clean oldheaders: Clear the old headers under the cache directory

    • yum clean, yum clean all (= yum clean packages; yum clean oldheaders) :Clear the software packages and old headers under the cache directory

Example 1

Install pam-devel

[root@www ~]# yum install pam-devel
Setting up Install Process
Parsing package install arguments
Resolving Dependencies <==First check the software's dependency issues
--> 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 <== Similarly, resolve the attribute dependency issue 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)  <== Good, there is no attribute dependency issue, simply removing a 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

Use the functionality of yum 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 <== Below are the '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)is one of the best yum sources in China, both in terms of speed and software versions, which are very good.

Set the yum source to163 yum can improve the speed of software package installation and update, while avoiding some common software versions that cannot be found.

Installation Steps

Firstly, 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 of the repo file and place it in /etc/yum.repos.d/ (Please make a backup before the operation)

  • 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

In addition to NetEase, there are other good yum sources in China, such as USTC and Sohu.

Check the installation method of USTC's yum source:https://lug.ustc.edu.cn/wiki/mirrors/help/centos

Check the installation method of sohu's yum source: http://mirrors.sohu.com/help/centos.html