Detailed explanation of Yum under CentOS

Source: Internet
Author: User

Detailed explanation of Yum under CentOS

In general, the Redhat and Fedora software installation commands are rpm, but the biggest trouble with installing the software with rpm is to manually find a series of dependencies required to install the software. This is super troublesome, if the software does not need to be uninstalled, it is annoying that other software cannot be used because the dependency is detached. Happily, Fedora finally launched the command yum similar to apt in ubuntu, making it easy to install the Fedora software.
Yum has the following features:
* Multiple resource libraries (Repository) can be configured simultaneously)
* Simple configuration file (/etc/yum. conf)
* Automatically solves the dependency problem when rpm packages are added or deleted.
* Easy to use
* Maintain consistency with the RPM Database

Yum, short for Yellow dog Updater Modified, was initially developed by Terra Soft, a developer of the yellow dog release and written in python. It was also called yup (yellow dog updater ), after being improved by Duke's Linux @ Duke Development Team, this name is available. Yum is designed to automatically upgrade, install/remove rpm packages, collect rpm package information, check dependencies, and automatically prompt users to resolve them. The key to yum is to have a reliable repository. As the name suggests, this is the software repository. It can be an http or ftp site, or a local software pool, but it must contain the rpm header, the header contains various rpm package information, including descriptions, functions, provided files, dependencies, and so on. only by collecting and analyzing these headers can we automate the remaining tasks.

1. all configuration information of yum is stored in a file named yum. in the conf configuration file, it is usually located in the/etc directory, which is the top priority of the entire yum system. I checked this file in F7. Let's take a look:

[Hanlong @ wh_eric F7 common documentation] $ sudo more/etc/yum. conf
[Main]
Cachedir =/var/cache/yum
Keepcache = 0
Debuglevel = 2
Logfile =/var/log/yum. log
Exactarch = 1
Obsoletes = 1
Gpgcheck = 1
Plugins = 1
Metadata_expire = 1800
# Put your repos here or in separate files named file. repo
# In/etc/yum. repos. d

The following is a brief description of this document:
Cachedir: directory of the yum cache, where yum stores the downloaded rpm package and database, generally/var/cache/yum.
Debuglevel: debug level, 0-10. The default value is 2.
Logfile: the log file of yum. The default value is/var/log/yum. log.
Exactarch has two options: 1 and 0, indicating whether to upgrade only the same package as the cpu system of your installation package. If it is set to 1, if you have installed an i386 rpm, yum will not be upgraded with a 686 package.
Gpgchkeck = there are two options: 1 and 0, which respectively indicate whether or not to perform gpg verification. If this option is not selected, it is also checked by default.

2. Well, the next step is to use yum. First, use yum to upgrade the software. Most yum operations must have the permissions of Super Users. Of course, you can use sudo.
Yum update is required. yum downloads the rpm header from the header directory of the server and stores it in the local cache. This may take some time, but what is the cost of the time compared with the convenience provided by yum? After the header is downloaded, yum determines whether an updatable software package exists. If yes, yum will ask you for your opinion and whether it is updated. Let's say y, it is always good to keep the system up to date. At this time, yum starts to download the software package and install it by calling rpm. This may take some time, depending on the number of software to be updated and network conditions, in case the network is disconnected, it doesn't matter. You can do it again. After the upgrade, you only need to use yum check-update every day to check whether there are any new ones. If yes, use yum update to keep the system up-to-date and block all discovered vulnerabilities. Use yum update packagename to upgrade a single package.
Now we can simply list some commands for yum software upgrade:

(Update: I used rpm to install wine one by one. I first installed the link and then installed the wine MAIN package. But I just found a good post on the forum, install yum locally. The parameter is-localinstall.
$ Yum localinstall wine -*
In this way, yum will automatically install all dependencies without the need to install rpm one by one, saving a lot of work.
There is another parameter similar to this one:
$ Yum localupdate wine -*
If a new version of wine is available and you download it locally, you can update wine locally .)

1. List all software updates

Command: yum check-update

2. Install all Update Software

Command: yum update

3. Only install the specified Software

Command: yum install

4. Update only the specified Software

Command: yum update

5. list all the software that can be installed

Command: yum list

3. Use yum to install and uninstall software. The premise is that the software packages installed by yum are in rpm format.
The installation command is: yum install xxx. yum queries the database to check whether this software package exists. If yes, check its dependency conflict. If no dependency conflict exists, download and install it; if yes, you will receive a prompt asking if you want to install dependencies at the same time or delete conflicting packages. You can make your own judgment.
The DELETE command is yum remove xxx. Like the installation command, yum also queries the database and provides a prompt to solve the dependency.

1. install the software package with YUM

Command: yum install

2. Use YUM to delete a software package

Command: yum remove

4. Use yum to query the software you want to install
We often encounter such a situation, we want to install a software, only know it is related to a certain aspect, but cannot know its name. In this case, the yum query function takes effect. You can use commands such as yum search keyword to search. For example, if you want to install Instant Messenger, but you don't know what it is, you can use commands such as yum search messenger to search, yum searches for all available rpm descriptions and lists all rpm packages related to messeger. Therefore, we may get gaim, kopete, and so on, and select from them.
Sometimes we install a package without knowing its purpose. We can use the yum info packagename command to obtain information.

1. Use YUM to find the Software Package
Command: yum search
2. List all installable software packages
Command: yum list
3. list all updatable software packages
Command: yum list updates
4. list all installed software packages
Command: yum list installed
5. list all software packages installed but not in Yum Repository
Command: yum list extras
6. List the specified software packages
Command: yum list

7. Use YUM to obtain the software package information
Command: yum info

8. list information about all software packages
Command: yum info
9. list information of all updatable software packages
Command: yum info updates
10. list information about all installed software packages
Command: yum info installed
11. list information about all software packages installed but not in Yum Repository
Command: yum info extras
12. List the files provided by the Software Package
Command: yum provides

5. Clear YUM Cache

Yum stores the downloaded software package and header in the cache, but does not automatically delete it. If we think they occupy disk space, we can use the yum clean command to clear them. More accurately, we use yum clean headers to clear the header and yum clean packages to clear the downloaded rpm package, yum clean all clear all

1. Clear the software packages under the cache directory (/var/cache/yum)

Command: yum clean packages

2. Clear headers under the cache directory (/var/cache/yum)

Command: yum clean headers

3. Clear the old headers under the cache directory (/var/cache/yum)

Command: yum clean oldheaders

4. Clear the software packages and old headers in the cache directory (/var/cache/yum ).

Command: yum clean, yum clean all (= yum clean packages; yum clean oldheaders)

You can use man to view all the preceding command parameters:

[Hanlong @ wh_eric F7 common documentation] $ man yum

FROM:http://han-long.cn/blog/archives/45

Yum features
    * Multiple resource libraries (Repository) can be configured simultaneously)
    * Simple configuration file (/etc/yum. conf)
    * Automatically solves the dependency problem when rpm packages are added or deleted.
    * Easy to use
    * Maintain consistency with the RPM Database
Yum installation, haha, comes with Fedora!
# Rpm-ivh yum-2.0.4-2.noarch.rpm

Iv. yum Configuration
Note: you can modify and add the resource library in the configuration file to accelerate the download speed and have more updatable rpm packages.
Replace all content in/etc/yum. conf
[Main]
Cachedir =/var/cache/yum
Debuglevel = 2
Logfile =/var/log/yum. log
Pkgpolicy = newest
Distroverpkg = fedora-release
Tolerant = 1
Exactarch = 1

[Fedora-us-1]
Name = Fedora Core 1 -- Fedora US mirror
Base url = ftp://mirrors.kernel.org/fedora.us/fedora/fedora/1/i386/yum/ OS

[Fedora-us-1-updates]
Name = Fedora Core 1 updates -- Fedora US mirror
Base url = ftp://mirrors.kernel.org/fedora.us/fedora/fedora/1/i386/yum/updates

[Fedora-us-1-stable]
Name = Fedora Linux (stable) for Fedora Core 1 -- Fedora US mirror
Base url = ftp://mirrors.kernel.org/fedora.us/fedora/fedora/1/i386/yum/stable

[Freshrpms]
Name = Fedora Linux $ releasever-$ basearch-freshrpms
Baseurl = http://ayo.freshrpms.net/fedora/linux/?releasever/?basearch/freshrpms

V. yum Application
Note: When the yum or yum resource library is updated for the first time, yum will automatically download all the required headers and place them in the/var/cache/yum Directory, which may take a long time.

Check which update rpm packages are available
# Yum check-update

Install the rpm package so that xmms can play mp3
# Yum install xmms-mp3

Install mplayer and install related software automatically
# Yum install mplayer

Delete the licq package and delete the packages that are dependent on the package.
# Yum remove licq
Note: You will also be prompted to delete licq-gnome, licq-qt, and licq-text, which is very convenient.

System update (update all rpm packages that can be upgraded, including kernel)
# Yum-y update

Perform system updates on a regular basis every day
# Chkconfig yum on
# Service yum start

6. yum instructions
* Update the rpm package

Check the updatable rpm package
# Yum check-update

Update all rpm packages
# Yum update

Update the specified rpm package, such as updating the kernel and kernel source
# Yum update kernel-source

For large-scale version upgrades, unlike yum update, the old obsolete package is also upgraded.
# Yum upgrade

* Installation and deletion of rpm packages

Install rpm packages like xmms-mp3
# Yum install xmms-mp3

Delete an rpm package, including packages that depend on the package
# Yum remove licq
Note: You will also be prompted to delete licq-gnome, licq-qt, and licq-text.

* Parameters related to yum temporary storage (/var/cache/yum /)
Clear temporary rpm package files
# Yum clean packages

Clear temporary rpm header files
# Yum clean headers

Clear the existing rpm header file
# Yum clean oldheaders

Clear existing rpm header files and package files
# Yum clean or # yum clean all
Note: equivalent to yum clean packages + yum clean oldheaders

* Rpm package list

List all rpm packages that can be installed or updated in the resource library
# Yum list

List specific rpm packages that can be installed, updated, and installed in the resource library
# Yum list mozilla
# Yum list mozilla *
Note: Match characters can be used in rpm package names, for example, to list all rpm packages starting with mozilla

List all updates to the rpm package in the resource library
# Yum list updates

List all installed rpm packages
# Yum list installed

List rpm packages installed but not included in the resource library
# Yum list extras
Note: download and install the rpm package from other websites

* Rpm package information display (the info parameter is the same as the list)

Lists information about all rpm packages that can be installed or updated in the resource library.
# Yum info

Lists the specific information of rpm packages that can be installed or updated and installed in the resource library.
# Yum info mozilla
# Yum info mozilla *
Note: Match characters can be used in rpm package names, such as listing all rpm packages starting with mozilla

Lists information about all the rpm packages that can be updated in the resource library.
# Yum info updates

Lists information about all installed rpm packages.
# Yum info installed

Lists the installed rpm packages that are not included in the resource library.
# Yum info extras
Note: Download the installed rpm package information from other websites.

* Search for an rpm package
Search for rpm packages matching specific characters
# Yum search mozilla
Note: Search for rpm package names and package descriptions

Search for rpm packages with specific file names
# Yum provides realplay

7. Securely update the rpm package of freshrpms.net
Install the GPG key of freshrpms.net
# Rpm -- importhttp: // freshrpms.net/packages/RPM-GPG-KEY.txt

Edit/etc/yum. conf and add the following information to the end.
[Freshrpms]
Name = Fedora Linux $ releasever-$ basearch-freshrpms
Baseurl = http://ayo.freshrpms.net/fedora/linux/?releasever/?basearch/freshrpms
Gpgcheck = 1

Note:
Check GPG Key
# Rpm-qa gpg-pubkey *

Show Key information
# Rpm-qi gpg-pubkey-e42d547b-3960bdf1

Delete Key
# Rpm e gpg-pubkey-e42d547b-3960bdf1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.