Yum: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(40 intermediate revisions by the same user not shown)
Line 7: Line 7:


* [[Linux#Commands|Linux Commands]]
* [[Linux#Commands|Linux Commands]]
* [[dnf]]


=Overview=
=Overview=
Line 16: Line 17:
The configuration file contains, among other things, the location of the log file (by default <tt>/var/log/yum.log</tt>).
The configuration file contains, among other things, the location of the log file (by default <tt>/var/log/yum.log</tt>).


<tt>yum</tt> looks for repository definitions, which are <tt>.repo</tt> files kept in <tt>/etc/yum.repos.d/</tt>. All files with the .repo file extension in this directory are read by <tt>yum</tt>. More information about configured repository can be obtained with <tt>[[#repolist|yum repolist]]</tt>.
<tt>yum</tt> looks for local repository definitions. More details are found in the [[#Yum_Repositories|Yum Repositories]] section
=Installation=
==Installation on RHEL8==
https://www.geeksforgeeks.org/installation-and-configuration-of-yum-in-red-hat-linux-8/
 
=Yum Repositories=
{{External|[https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sec-Configuring_Yum_and_Yum_Repositories Configuring Yum and Yum Repositories]}}
 
Yum looks into local repository definitions, which are <tt>.repo</tt> files kept in <tt>/etc/yum.repos.d/</tt>. All files with the .repo file extension in this directory are read by <tt>yum</tt>. More information about configured repository can be obtained with <tt>[[#repolist|yum repolist]]</tt>.


To query the content of a specific repository, use <tt>[[#repository-packages|yum repository-packages]]</tt>.
To query the content of a specific repository, use <tt>[[#repository-packages|yum repository-packages]]</tt>.
To install a new repository, see [[#Adding_a_Repository_Definition|Adding a Repository Definition]] below.
==Yum Variables==
{{External|[https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sec-Configuring_Yum_and_Yum_Repositories#sec-Using_Yum_Variables Using Yum Variables]}}
Yum supports a series of built-in variables, which can be used in all its configuration files, including repository definitions:
===$releasever===
This variable references the release version of Red Hat Enterprise Linux. Yum obtains the value of $releasever from the distroverpkg=value line in the /etc/yum.conf configuration file. If there is no such line in /etc/yum.conf, then yum infers the correct value by deriving the version number from the redhat-releaseproduct package that provides the redhat-release file.
=Exclusion=
Yum can be configured to exclude packages from updates to prevent accidental upgrades when we don't want to upgrade, by adding package names to the "exclude" directive in /etc/yum.conf.
Example:
exclude= tuned-profiles-atomic-openshift-node  atomic-openshift-tests  atomic-openshift-sdn-ovs  atomic-openshift-recycle  atomic-openshift-pod  atomic-openshift-node  atomic-openshift-master  atomic-openshift-dockerregistry  atomic-openshift-clients-redistributable  atomic-openshift-clients  atomic-openshift  docker*1.20*  docker*1.19*  docker*1.18*  docker*1.17*  docker*1.16*  docker*1.15*  docker*1.14*  docker*1.13*


=Commands=
=Commands=
Line 26: Line 54:
Used to list various information about available packages - packages available from the repositories described in <tt>/etc/yum.repos.d/*.repo</tt>.
Used to list various information about available packages - packages available from the repositories described in <tt>/etc/yum.repos.d/*.repo</tt>.


===installed===
====installed====


Gets a list of installed packages:
Gets a list of installed packages:


<pre>
yum list installed
yum list installed
 
</pre>
To filter, use <tt>| grep</tt>:
 
yum list installed | grep [-i] <package-name>
 
Example of positive hit:
 
[root@ns ~]# yum list installed | grep [-i]  httpd
httpd.x86_64                    2.4.6-40.el7                @rhel-7-server-rpms
httpd-tools.x86_64              2.4.6-40.el7                @rhel-7-server-rpms


==repolist==
====available====


Displays information about configured repositories - repositories described in <tt>/etc/yum.repos.d/*.repo</tt> files.  
Gets a list of all packages in all available repositories.


<pre>
<pre>
yum repolist [-v] [repository-id]
yum list available
</pre>
</pre>


where "repository-id" is the repository identifier declared between square brackets in the .repo file.
To filter, use <tt>| grep</tt>.
 
==info==


==repository-packages==
Without arguments, the command lists all packages available from all installed repositories:


<pre>
<pre>
yum repository-packages dockerrepo list
yum info
</pre>
</pre>
To get information about a specific package:


<pre>
<pre>
yum repository-packages dockerrepo info
yum info <package-name>
</pre>
</pre>


=Recipes=
This can be used for information on packages that already have been installed or on package that ''has't been installed yet''. If the package has been installed, <tt>yum info</tt> will report <tt>Installed Packages</tt>, otherwise will say <tt>Available</tt>.


==Queries==
==repolist==


===Find Packages that Might Contain a Certain Command===
Displays information about configured repositories - repositories described in <tt>/etc/yum.repos.d/*.repo</tt> files.


<pre>
<pre>
yum provides sealert
yum repolist [-v] [repository-id]
</pre>
</pre>


===Find Whether a Package is Installed===
where "repository-id" is the repository identifier declared between square brackets in the .repo file.
 
==search==


<pre>
<pre>
yum list installed | grep <package-name>
yum search <string>
</pre>
</pre>


Example of positive hit:
==provides==
 
"provides" can be used to find packages that might contain a certain command:


<pre>
<pre>
[root@ns ~]# yum list installed | grep httpd
yum provides sealert
httpd.x86_64                    2.4.6-40.el7                @rhel-7-server-rpms
httpd-tools.x86_64              2.4.6-40.el7                @rhel-7-server-rpms
</pre>
</pre>


===List of Everything Available from Installed Repositories===
==repository-packages==


<pre>
<pre>
yum info
yum repository-packages dockerrepo list
</pre>
</pre>
===Information about a Specific Package===


<pre>
<pre>
yum info <package-name>
yum repository-packages dockerrepo info
</pre>
</pre>


This can be used for information on packages that already have been installed or on package that ''has't been installed yet''. If the package has been installed, <tt>yum info</tt> will report <tt>Installed Packages</tt>, otherwise will say <tt>Available</tt>.
==install==


===Generic Search===
Installs the specified package.


<pre>
<pre>
yum search <string>
yum install <package-name>
</pre>
</pre>


==Update All Packages==
==localinstall==
 
{{External|https://serverfault.com/questions/940791/whats-the-difference-between-yum-install-local-path-and-yum-localinstall}}


<pre>
==update==
yum -y update
</pre>


==Update a Package==
Updates the specified package.


<pre>
<pre>
Line 110: Line 150:
</pre>
</pre>


==Install a Package==
To update all packages, see "[[#Update_All_Packages|Update All Packages]]"
 
==<span id='erase'></span>remove, erase==
 
<tt>remove</tt> and <tt>erase</tt> are equivalent.
 
Removes the specified package and its dependents from the system.
 
<syntaxhighlight lang='bash'>
yum remove <package-name>
</syntaxhighlight>
 
==clean==
Remove cached data.
<syntaxhighlight lang='bash'>
yum clean all
</syntaxhighlight>
 
=Update All Packages=


<pre>
<pre>
yum install <package-name>
yum -y update
</pre>
</pre>


==Uninstall a Package==
=Adding a Repository Definition=


<pre>
{{Internal|Install CentOS-Base Repository|Install CentOS-Base Repository}}
yum remove <package-name>
{{Internal|Install EPEL Repository|Install EPEL Repository}}
</pre>
{{Internal|Docker_Linux_Installation#Setting_a_yum_Repository|Adding a docker Repository}}
{{Internal|Using_yum_with_registry.access.redhat.com_Images#Overview|Add an Entitled registry.access.redhat.com Repository}}


==Adding a Repository Definition==
=yum-config-manager=


{{Internal|Docker_Installation#Setting_a_yum_Repository|Setting a <tt>yum</tt> Repository for Docker}}
<syntaxhighlight lang='bash'>
yum install yum-utils
</syntaxhighlight>

Latest revision as of 05:08, 3 May 2022

External

Internal

Overview

yum is an interactive, rpm-based package manager. It can automatically perform system updates, including dependency analysis and obsolete processing based on repository metadata. It can also perform installation of new packages, removal of old packages and perform queries on the installed and/or available packages among many other commands/services.

yum is configured in /etc/yum.conf.

The configuration file contains, among other things, the location of the log file (by default /var/log/yum.log).

yum looks for local repository definitions. More details are found in the Yum Repositories section

Installation

Installation on RHEL8

https://www.geeksforgeeks.org/installation-and-configuration-of-yum-in-red-hat-linux-8/

Yum Repositories

Configuring Yum and Yum Repositories

Yum looks into local repository definitions, which are .repo files kept in /etc/yum.repos.d/. All files with the .repo file extension in this directory are read by yum. More information about configured repository can be obtained with yum repolist.

To query the content of a specific repository, use yum repository-packages.

To install a new repository, see Adding a Repository Definition below.

Yum Variables

Using Yum Variables

Yum supports a series of built-in variables, which can be used in all its configuration files, including repository definitions:

$releasever

This variable references the release version of Red Hat Enterprise Linux. Yum obtains the value of $releasever from the distroverpkg=value line in the /etc/yum.conf configuration file. If there is no such line in /etc/yum.conf, then yum infers the correct value by deriving the version number from the redhat-releaseproduct package that provides the redhat-release file.

Exclusion

Yum can be configured to exclude packages from updates to prevent accidental upgrades when we don't want to upgrade, by adding package names to the "exclude" directive in /etc/yum.conf.

Example:

exclude= tuned-profiles-atomic-openshift-node  atomic-openshift-tests  atomic-openshift-sdn-ovs  atomic-openshift-recycle  atomic-openshift-pod  atomic-openshift-node  atomic-openshift-master  atomic-openshift-dockerregistry  atomic-openshift-clients-redistributable  atomic-openshift-clients  atomic-openshift  docker*1.20*  docker*1.19*  docker*1.18*  docker*1.17*  docker*1.16*  docker*1.15*  docker*1.14*  docker*1.13*

Commands

list

Used to list various information about available packages - packages available from the repositories described in /etc/yum.repos.d/*.repo.

installed

Gets a list of installed packages:

yum list installed

To filter, use | grep:

yum list installed | grep [-i] <package-name>

Example of positive hit:

[root@ns ~]# yum list installed | grep [-i]  httpd
httpd.x86_64                     2.4.6-40.el7                @rhel-7-server-rpms
httpd-tools.x86_64               2.4.6-40.el7                @rhel-7-server-rpms

available

Gets a list of all packages in all available repositories.

yum list available

To filter, use | grep.

info

Without arguments, the command lists all packages available from all installed repositories:

yum info

To get information about a specific package:

yum info <package-name>

This can be used for information on packages that already have been installed or on package that has't been installed yet. If the package has been installed, yum info will report Installed Packages, otherwise will say Available.

repolist

Displays information about configured repositories - repositories described in /etc/yum.repos.d/*.repo files.

yum repolist [-v] [repository-id]

where "repository-id" is the repository identifier declared between square brackets in the .repo file.

search

yum search <string>

provides

"provides" can be used to find packages that might contain a certain command:

yum provides sealert

repository-packages

yum repository-packages dockerrepo list
yum repository-packages dockerrepo info

install

Installs the specified package.

yum install <package-name>

localinstall

https://serverfault.com/questions/940791/whats-the-difference-between-yum-install-local-path-and-yum-localinstall

update

Updates the specified package.

yum update <package-name>

To update all packages, see "Update All Packages"

remove, erase

remove and erase are equivalent.

Removes the specified package and its dependents from the system.

yum remove <package-name>

clean

Remove cached data.

yum clean all

Update All Packages

yum -y update

Adding a Repository Definition

Install CentOS-Base Repository
Install EPEL Repository
Adding a docker Repository
Add an Entitled registry.access.redhat.com Repository

yum-config-manager

yum install yum-utils