Useful Yum Variables

If you’re familiar with the Linux operating system, you’ve probably heard of Yum. Yum is a package manager that makes it easy to install and manage software on your Linux machine. It’s a powerful tool that can help you automate software installations, keep your system up to date, and even resolve dependencies between packages.

In this article, we’ll take a look at some useful Yum variables that can help you get more out of your package management. From customizing your repositories to setting up proxy servers, these variables will make your life easier and your software management more efficient.

Customizing Your Repositories

One of the most useful Yum variables is the repository configuration file. This file lets you customize the repositories you use with Yum, including the order in which they are checked for updates. This can be particularly useful if you’re using multiple repositories for different packages, or if you want to prioritize a specific repository over others.

Here’s an example of a Yum repository configuration file:

[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

In this example, we have two repositories – “base” and “updates”. The “base” repository contains the core packages for CentOS, while the “updates” repository contains updates for these packages. The “baseurl” variable specifies the URL for each repository, and the “gpgcheck” variable tells Yum to check for GPG signatures on packages before installing them.

Setting Up a Proxy Server

If you’re behind a firewall or using a proxy server, you may need to configure Yum to use the proxy server in order to access the Internet. The “http_proxy” variable is used for this purpose. Here’s an example:

export http_proxy=<a href="http://proxy.example.com:8080/">http://proxy.example.com:8080/</a>

In this example, we’re setting the “http_proxy” variable to the URL of our proxy server. Note that the variable is exported so that it’s available in the environment.

Excluding Packages from Updates

Sometimes, you may want to exclude specific packages from being updated. This could be because you’re using a custom version of a package, or because you’re having compatibility issues with a new version. The “exclude” variable is used for this purpose. Here’s an example:

exclude=package1 package2 package3

In this example, we’re excluding three packages from being updated – “package1”, “package2”, and “package3”.

Configuring Yum Priorities

Yum priorities is a plugin that allows you to set priorities for packages from different repositories. This can be useful if you’re using multiple repositories, and you want to ensure that packages from one repository take precedence over packages from another repository. Here’s an example:

[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
priority=1

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
priority=2

In this example, we’ve added a “priority” variable to each repository. The “base” repository has a priority of 1, while the “updates” repository has a priority of 2. This means that Yum will check the “base” repository first when installing packages, and only use the “updates” repository if a package is not available in the “base” repository.

Setting Package Installation Options

Yum allows you to set options for package installations, such as the installation location, whether to upgrade packages, and whether to install dependencies. The “installroot” variable is used to set the installation location, while the “upgrade” variable is used to specify whether to upgrade packages. The “installonly_limit” variable can be used to set the maximum number of packages that can be installed at once. Here’s an example:

installroot=/opt/ 
upgrade=yes 
installonly_limit=3

In this example, we’re specifying that packages should be installed to the “/opt/” directory, that packages should be upgraded if newer versions are available, and that a maximum of 3 packages can be installed at once.

Managing Package Groups

Yum also allows you to manage package groups, which are collections of packages that are installed together. The “group_package_types” variable is used to specify the types of packages that should be included in groups. Here’s an example:

group_package_types=mandatory default optional

In this example, we’re specifying that mandatory, default, and optional packages should be included in groups.

Cleaning Up the Yum Cache

Finally, the “clean_requirements_on_remove” variable is used to specify whether to remove packages that are no longer required after removing a package. This can be useful for freeing up disk space and keeping your system clean. Here’s an example:

clean_requirements_on_remove=1

In this example, we’re specifying that packages that are no longer required should be removed after removing a package.

Conclusion

In this article, we’ve looked at some useful Yum variables that can help you get more out of your package management. Whether you’re customizing your repositories, setting up a proxy server, or managing package groups, these variables will make your life easier and your software management more efficient. So, next time you’re working with Yum, be sure to give these variables a try!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

seven + 17 =

Related Articles