YouTip LogoYouTip

Linux Yum

> yum is the default package manager for CentOS 5/6/7 and RHEL 5/6/7. It has relatively poor dependency resolution performance and can easily lag in complex dependency scenarios. Official maintenance has now been discontinued. > > > Starting from CentOS 8, RHEL 8, and later versions, the system defaults to using the successor tool (#); dnf is backward-compatible with the vast majority of yum commands, and the usage habits are basically the same. yum (Yellow dog Updater, Modified) is a shell-based front-end package manager for Fedora, RedHat, and SUSE. **Starting from CentOS 8, RHEL 8, and later versions, please use the dnf command: [ Based on RPM package management, it can automatically download and install RPM packages from specified servers, automatically handle dependency relationships, and install all dependent packages at once, eliminating the tedious process of downloading and installing them one by one. yum provides commands to search for, install, and delete individual packages, groups of packages, or even all packages, and the commands are concise and easy to remember. ### yum Syntax yum [package ...] * **options:** Optional. Options include -h (help), -y (automatically answer "yes" to all prompts during installation), -q (quiet mode, do not display installation process), etc. * **command:** The operation to perform. * **package:** The name of the package to install. * * * ## Common yum Commands * 1. List all updatable packages: yum check-update * 2. Update all packages: yum update * 3. Install only specified packages: yum install * 4. Update only specified packages: yum update * 5. List all installable packages: yum list * 6. Remove a package: yum remove * 7. Search for a package: yum search * 8. Clean the cache: * yum clean packages: Clean the packages in the cache directory. * yum clean headers: Clean the headers in the cache directory. * yum clean oldheaders: Clean the old headers in the cache directory. * yum clean, yum clean all (= yum clean packages; yum clean oldheaders): Clean both packages and old headers in the cache directory. ### Example 1 Installing pam-devel [root@www ~]# yum install pam-devel Setting up Install ProcessParsing 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……(omitted) ### Example 2 Removing pam-devel [root@www ~]# yum remove pam-devel Setting up Remove ProcessResolving Dependencies Running transaction check ---> Package pam-devel.i386 0:0.99.6.2-4.el5 set to be erased --> Finished Dependency ResolutionDependencies 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 were no attribute dependency issues, just removing a single packageIs this ok [y/N]: y Downloading Packages:Running rpm_check_debug Running Transaction TestFinished Transaction TestTransaction Test SucceededRunning Transaction Erasing : pam-devel ######################### [1/1]Removed: pam-devel.i386 0:0.99.6.2-4.el5Complete! ### Example 3 Using yum's functionality to find 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' 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 Sources NetEase (163) yum source is one of the better domestic yum sources, both in terms of speed and software versions. Setting the yum source to 163 yum can speed up package installation and updates, and also avoid issues where common software versions cannot be found. ### 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 corresponding version repo file and place it in /etc/yum.repos.d/ (please make a backup before proceeding) * (http://mirrors.163.com/.help/CentOS5-Base-163.repo) :http://mirrors.163.com/.help/CentOS5-Base-163.repo * (http://mirrors.163.com/.help/CentOS6-Base-163.repo) :http://mirrors.163.com/.help/CentOS6-Base-163.repo * (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 Run the following commands to generate the cache yum clean all yum makecache Besides NetEase, there are other good domestic yum sources, such as USTC and Sohu. For the USTC yum source, see the installation method: [https://lug.ustc.edu.cn/wiki/mirrors/help/centos](https://lug.ustc.edu.cn/wiki/mirrors/help/centos) For the Sohu yum source installation method, see: [http://mirrors.sohu.com/help/centos.html](http://mirrors.sohu.com/help/centos.html) Alibaba Cloud source: [https://developer.aliyun.com/mirror/centos](https://developer.aliyun.com/mirror/centos)
← Js VoidLinux Vim β†’