<transfer>CentOS Yum command details

 

CentOS Yum Command Details

Disadvantages of rpm installation: 
As we all know, the software installation command for Redhat and Fedora is rpm. Need to manually find a series of dependencies required to install the software, not to mention super troublesome, if the software needs to be uninstalled, it is very annoying that other software cannot be used because a certain dependency is uninstalled. Happily, Fedora has finally launched a command yum similar to apt in ubuntu, which makes the installation of Fedora software simple and easy. 

Advantages of yum: 

  • Multiple repositories can be configured at the same time (Repository)
  • Concise configuration file (/etc/yum.conf)
  • Automatically resolve dependency problems encountered when adding or removing rpm packages
  • easy to use
  • Maintain consistency with the RPM database


Introduction to yum: 
yum is the abbreviation of Yellow dog Updater Modified. It was originally developed by Terra Soft, the developer of the yellow dog distribution. It was written in python. It was also called yup (yellow dog updater) at that time. The Linux@Duke development team made improvements, hence the name. The purpose of yum is to automatically upgrade, install/remove rpm packages, collect information about rpm packages, check dependencies and automatically prompt users to resolve them. The key point of yum is to have a reliable repository . As the name suggests, this is a software repository. It can be an http or ftp site, or a local software pool, but it must contain the rpm header, which includes various rpm packages. Information, including descriptions, features, provided files, dependencies, etc. It is these headers that are collected and analyzed to automate the rest of the task. 

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

Html code   Favorite code
  1. [hanlong@wh_eric F7 common documents]$ sudo more /etc/yum.conf  
  2. [main]  
  3. cachedir =/var/cache/yum  
  4. keepcache = 0  
  5. debuglevel=2  
  6. logfile=/var/log/yum.log  
  7. exactfile = 1  
  8. obsoletes=1  
  9. gpgcheck=1  
  10. plugins=1  
  11. metadata_expire=1800  
  12. # PUT YOUR REPOS HERE OR IN separate files named file.repo  
  13. # in /etc/yum.repos.d  


The following is a brief description of this document: 

  • cachedir: The directory where yum caches, where yum stores downloaded rpm packages and databases, usually /var/cache/yum.
  • debuglevel: debug level, 0──10, default is 2
  • logfile: yum's log file, the default is /var/log/yum.log.
  • exactarch, there are two options 1 and 0, which means whether to upgrade only the package that is consistent with the cpu system of the package you installed. If it is set to 1, if you install an i386 rpm, yum will not use the 686 package to upgrade .
  • gpgchkeck= There are two options, 1 and 0, which represent whether to perform gpg verification. If there is no such item, it seems to be checked by default.


yum use-upgrade: 
The next step is the use of yum. First, use yum to upgrade the software. Most of the operations of yum must have superuser privileges. Of course, sudo can be used. 
When using yum for the first time or the yum repository is updated , yum will download the rpm header from the server's header directory and put it in the local cache , which may take a certain amount of time, but compared to yum Convenience, what is the cost of all this time? After the header is downloaded, yum will judge whether there is an updateable software package. If so, it will ask your opinion, whether to update it, or say y, it is always good to keep the system up to date, then yum starts to download the software Package and use rpm to install, which may take a certain amount of time, depending on the number of software to be updated and network conditions, in case the network is disconnected, it doesn't matter, just do it again. After the upgrade is complete, you only need to use yum check-update every day to check whether it is updated. If there is, use yum update to update it, keep the system up-to-date at all times, and block all discovered loopholes. Use yum update packagename to upgrade an individual package. 

yum use - install and delete: 
use yum to install and uninstall software, there is a premise that the packages installed by yum are in rpm format . The installation command is, yum install xxx, yum will query the database to see if there is such a package, and if so, check its dependency conflict. If there is no dependency conflict, then it is best to download and install it; if there is, it will be given. Prompt, ask if you want to install dependencies at the same time, or delete conflicting packages, you can make your own judgment to delete the command is, yum remove xxx, like installation, yum will also query the database and give tips to resolve dependencies. 

yum use - to query the software you want to install: 
We often encounter such a situation. When we want to install a software, we only know that it is related to a certain aspect, but we cannot know its name exactly. At this time, the query function of yum comes into play. You can use  a command such as yum search keyword to search. For example, if we want to install an Instant Messenger, but we don't know what it is, we may use a command such as yum search messenger to search, and yum will search for all available rpm descriptions. , list all the rpm packages related to messeger in the description, so we may get gaim, kopete, etc., and choose from them. 
Sometimes we also encounter a package installed, but do not know its purpose, we can use the command yum info packagename to get information. 

yum use - clear cache: 
yum will store downloaded packages and headers in the cache and will not delete them automatically. If we feel that they are taking up disk space, we can use the yum clean command to remove them. More precise usage is yum clean headers to remove headers, yum clean packages to remove downloaded rpm packages, and yum clean all to remove all 

yum downloads without installing rpm packages: 
Sometimes, we need to download an rpm package, just download it and copy it for other machines to use. When yum installs the rpm package, we must first download the rpm package and then install it, so using yum can be done by downloading only without installing. The implementation of this function depends on the yum-downloadonly package (or the name yum-plugin-downloadonly, use yum search yum to find the corresponding package) 
1. yum install -y yum-downloadonly.noarch(yum-plugin-downloadonly.noarch) 
2. Download an rpm package without installing it: yum install test.rpm -y --downloadonly 
3. Download an rpm package to the specified directory and do not install yum install test.rpm -y --downloadonly --downloaddir=/usr/local/src 

Html code   Favorite code
  1. Upgrade related commands:  
  2. yum update : install all updates  
  3. yum update xxx : update only the specified software  
  4. yum check-update : list all updatable software  
  5. yum list : list all installable software  
  6.   
  7. Install and delete related commands:  
  8. yum install xxx: install only the specified software  
  9. yum remove xxx: remove the specified package  
  10.   
  11. yum query related commands:  
  12. yum search : Use YUM to find packages  
  13. yum list : list all installable packages  
  14. yum list updates : list all updatable packages  
  15. yum list installed : list all installed packages  
  16. yum list extras : List all installed packages but not in Yum Repository  
  17. yum info xxx: Use YUM to get package information  
  18. yum info : List information about all packages  
  19. yum info updates : List all updateable package information  
  20. yum info installed : List all installed package information  
  21. yum info extras : List all installed packages that are not in the Yum Repository  
  22. yum provides : List which files are provided by the package  
  23.   
  24. yum cache related commands:  
  25. yum makecache : generate metadata cache  
  26. yum clean packages : Clear the packages in the cache directory (/var/cache/yum)  
  27. yum clean headers : Clear the headers in the cache directory (/var/cache/yum)  
  28. yum clean oldheaders : Clear the old headers in the cache directory (/var/cache/yum)  
  29. yum clean, yum clean all (= yum clean packages; yum clean oldheaders) : Clear the packages and old headers in the cache directory (/var/cache/yum)  
  30.   
  31. yum -y update : #Manual system update  
  32. yum install [-y] [rpm package name]: install the specified package in a non-interactive way (y is selected by default) 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326387482&siteId=291194637