Learn YUM configuration in Linux. Understand what is yum, features of yum, what is a repository, and how to configure it.
YUM is Yellow dog Updated Modified. It is developed to maintain an RPM-based system. RPM is the Redhat Package Manager. YUM is a package manager with below features –
- Simple install, uninstall, upgrade operations
- Automatic resolves software dependency
- Looks for more than one source for software
- Supports CLI and GUI
- Automatically detects architecture of the system and search for best-fit software version
- Works well with remote (network connectivity) and local (without network connectivity) repositories.
All these features made it the best package manager. In this article, we will walk through Yum configuration steps. You can also browse through below yum related posts :
- Yum automatic updates
- Download package using yum
- How to check if package is installed
- Package naming conventions
- YUM cheat sheet
YUM configuration basics
Yum configuration has repositories defined. Repositories are the places where package files
.rpm are located and yum searches, downloads files from repositories for installations. Repositories can be the local mount point file://path, remote FTP location
ftp://link, HTTP location link
http://login:password@link, https link or remote NFS mount point.
Yum configuration file is
/etc/yum.conf and repository configuration files are located under
/etc/yum.repos.d/ directory. All repository configuration files must have
.repo extension so than yum can identify them and read their configurations.
Typical repo configuration file entry looks like below :
[rhel-source-beta] name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhrl-source-beta]is a unique repository id.
nameis a human readable repository name
baseurlis the location from where packages should be scanned and fetched
enableddenotes if this repo is enabled or not i.e. yum should use it or not
gpgcheckenable/disable GPG signature check
gpgkeyis the location of GPG key
Out of these first 4 entries are mandatory for every repo location. Let’s see how to create a repo from the DVD ISO file.
Remember one repo configuration file can have more than one location listed.
You can even configure internet proxy for yum in this configuration file.
YUM repo configuration for DVD ISO
RPM-based Linux installation DVD has RPM files in it which are used to install packages at the time of OS installation. We can use this package and build our repo so that yum can use those packages!
First, you have to mount ISO file on system. Let’s assume we have mounted it on
/mnt/dvd. Now we have to create a yum repo file for it. Lets create file
/etc/yum.repos.d/ directory. It should look like :
[dvdiso] name=RedHat DVD ISO baseurl=file:///mnt/dvd enabled=1 gpgcheck=1 gpgkey=file:///mnt/dvd/RPM-GPG-KEY-redhat-6
Male sure you check the path of GPG key on your ISO and edit accordingly.
baseurl path will be a directory where
repodata directory & gpg file lives.
Thats it! Your repo is ready. You can check using
yum repolist command.
# yum repolist Loaded plugins: refresh-packagekit, security ... repo id repo name status dvdiso RedHat DVD ISO 25,459
In the above output, you can see repo is identified by yum. Now you can try installing any software from it with
yum install command.
Make sure your ISO is always mounted on the system even after a reboot (add an entry in /etc/fstab to run this repo successfully.
YUM repo configuration for http repo
There are many official and unofficial repositories are hosted on the internet and can be accessed over HTTP protocol. These repositories are large and may contain more packages than your DVD has. To use them in yum, your server should have an active internet connection and it should be able to connect with HTTP locations you are trying to configure.
Once connectivity is confirmed create new repo file for them e.g. named
weblocations.repo under directory
/etc/yum.repos.d/ with content as below (for example) :
[centos] name=CentOS Repository baseurl=http://mirror.cisp.com/CentOS/6/os/i386/ enabled=1 gpgcheck=1 gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6 [rhel-server-releases-optional] name=Red Hat Enterprise Linux Server 6 Optional (RPMs) mirrorlist=https://redhat.com/pulp/mirror/content/dist/rhel/rhui/server/6/$releasever/$basearch/optional/os enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release sslverify=1 sslclientkey=/etc/pki/rhui/content-rhel6.key sslclientcert=/etc/pki/rhui/product/content-rhel6.crt sslcacert=/etc/pki/rhui/cdn.redhat.com-chain.crt
In the above example, you can see 2 web locations are configured in the repo. First is HTTP for centOS whereas the second one is RHEL supplied with https mirror list. Since https protocol is used other SSL related config can be seen following it.
Time to check repo –
# yum repolist Loaded plugins: rhui-lb, security repo id repo name status centos CentOS Repository 5,062 rhui-REGION-rhel-server-releases-optional Red Hat Enterprise Linux Server 6 Optional (RPMs) 11,057
Both repo are identified by yum. Configuration is successful.
Read about yum server configuration for FTP, HTTP, and client-side yum configuration in our other articles.
YUM certificate error
If you have an issue with your Red Hat Network certificate you will see below error while executing
The certificate /usr/share/rhn/ULN-CA-CERT is expired. Please ensure you have the correct certificate and your system time is correct.
You need to update
rhn-client-tools package and it will update certificate details.
rhn-client-tools package is not installed properly you may see below error while executing
rhn-plugin: ERROR: can not find RHNS CA file: /usr/share/rhn/ULN-CA-CERT
In this case, you need to reinstall or update
rhn-client-tools package. If you are not using RHN on your server you can even safely remove this package from the system and get your