Sh - yum command (Yellowdog Updater Modified)

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

yum is a software package manager. It is a tool for installing, updating, and removing packages and their dependencies on RPM-based systems. It automatically computes dependencies and figures out what things should occur to install packages. It makes it easier to maintain groups of machines without having to manually update each one using rpm.

yum is wrapper around rpm.

Features include:

  • Support for multiple repositories
  • Simple configuration
  • Dependency calculation
  • Fast operation
  • RPM-consistent behavior
  • Package group support, including multiple-repository groups
  • Simple interface

up2date is now deprecated in favor of yum (Yellowdog Updater Modified). The entire stack of tools which installs and updates software in Red Hat Enterprise Linux 5.2 is now based on yum.

Advertising

3 - Repository Configuration

3.1 - Microsoft

# Import the key
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
# Create the repo metadata
sudo sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo'

3.2 - Oracle

The Oracle public yum server offers a free and convenient way to install packages from the Enterprise Linux and Oracle VM installation media via a yum client.

All configuration steps are detailed in the Oracle Public Yum home page

[root@oel11g yum.repos.d]# cat /etc/enterprise-release
Enterprise Linux Enterprise Linux Server release 5.3 (Carthage)  <------OEL 5 Update 3
  • Download and copy the appropriate yum configuration file in place:
[root@oel11g tmp]# cd /etc/yum.repos.d
[root@oel11g yum.repos.d]# dir
[root@oel11g yum.repos.d]# wget http://public-yum.oracle.com/public-yum-el5.repo
--21:01:30--  http://public-yum.oracle.com/public-yum-el5.repo
Resolving public-yum.oracle.com... 141.146.44.34
Connecting to public-yum.oracle.com|141.146.44.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1864 (1.8K) [text/plain]
Saving to: public-yum-el5.repo
 
100%[=======================================>] 1,864       --.-K/s   in 0s
 
21:01:30 (518 MB/s) - public-yum-el5.repo saved [1864/1864]
  • Open the yum configuration file in a text editor
  • Locate the section in the file for the repository you plan to update from, e.g. [el5_u3_base]
  • Change with vi enabled=0 to enabled=1
[root@oel11g yum.repos.d]# vi public-yum-el5.repo

Example:

[el5_u3_base]
name=Enterprise Linux $releasever U3 - $basearch - base
baseurl=http://public-yum.oracle.com/repo/EnterpriseLinux/EL5/3/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-el5
gpgcheck=1
enabled=1
Advertising

4 - Management

For the manipulation of package, see Sh - RPM package (RPM: Red Hat Package Manager)

4.1 - Configuration

/etc/yum.conf

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
 
#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
 
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
http_caching=packages

4.2 - Repository

  • List
yum repolist
  • repository Meta File location
ll /etc/yum.repos.d/*

4.3 - Whatprovides

Search a shared library

Example:

yum whatprovides 'libXrender.so.1'

Output:

Loaded plugins: ulninfo
libXrender-0.9.8-2.1.el7.i686 : X.Org X11 libXrender runtime library
Repo        : ol7_latest
Matched from:
Provides    : libXrender.so.1



libXrender-0.9.10-1.el7.i686 : X.Org X11 libXrender runtime library
Repo        : ol7_latest
Matched from:
Provides    : libXrender.so.1
Advertising

4.4 - Exclude

At the command line:

yum -x python-3 update
yum --exclude httpd,php update

In the the conf file file.

  • Exclude Single Package
exclude=python-3*        
  • Exclude Multiple Packages
exclude=httpd php        

In the repo file .repo in /etc/yum/repos.d/ or /etc/yum.repos.d directory with the exclude

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
exclude=python-3* 

5 - Documentation

For more information on yum:

man yum

6 - Reference

lang/bash/yum.txt · Last modified: 2019/02/20 16:19 by gerardnico