Objective
- Discuss package installers and their characteristics
- Explain what yum is
- Configure yum to use repositories
- Discuss the queries yum can be used for
- Verify, install, remove and upgrade packages using yum
Package Installers
Rpm and dpkg are lower level package utilities which deal with specific software package files and manage already installed software.
The higher level package management systems (such as yum, apt and zypper) work with databases of available software and incorporate the tools needed to find, install, update and uninstall software in a highly intelligent fashion.
- Can use both local and remote repositories as a source to install and update binary as well as source software packages
- Are used to automate the install, upgrade and removal of software packages
- Resolve dependencies automatically
- Save time because there is no need to either download packages manually or search out dependency information separately
The software repositories are provided by distributions and other independent software providers. The package installers maintain databases of available software derived from catalogs kept by the repositories. Unlike the low-level package tools, they have the ability to find and install dependencies automatically a critical feature.
What is YUM ?
Yum provides a front end for rpm. Its primary task is to fetch packages from multiple remote repositories and resolve dependencies among packages. It is used by the majority of distributions that use rpm, like:
- RHEL
- CentOS
- Scientific Linux
- Fedora
Yum caches information and databases to speed up performance. To remove some or all cached information one can run the command:
$ yum clear [ package | metadata | expire-cache | rpmdb | plugins | all ]
Yum has a number of modular expressions (plugins) and companion programs that can be found under
/usr/bin/yum*
and
/usr/sbin/yum*.
Configuring yum to use repositories
Repository configuration files are kept in
/etc/yum.repos.d/
And have a .repo extension.
$ ls -l /etc/yum.repos.d total 12 -rw-r--r--. 1 root root 1255 Oct 20 2015 fedora.repo -rw-r--r--. 1 root root 1270 Oct 20 2015 fedora-updates.repo -rw-r--r--. 1 root root 1328 Oct 20 2015 fedora-updates-testing.repo
A very simple repo file might look like
[repo-name] name=Description of the repository baseurl=http://somesystem.com/path/to/repo enabled=1 gpgcheck=1
The enabled option allow to toggle on and off the repository, also we can toggle the integrity check with the gpgcheck option.
Queries
Like rpm, yum can be used for queries such as searches. However it can not only search in the local machine but in remote repositories also.
- Search for packages with keyword in name
- $ sudo yum search keyword
- Tell us more about packages
- $ sudo yum list "*keyword*"
- Tell us about what is installed and what else is available
- $ sudo yum search keyword
- Display information about a package
- $ sudo yum info package
- Gives information about size, version, what repository it came from, a source URL, and a longer description. Wildcards can be given as in
- $ sudo yum info "libc*"
- Gives information about size, version, what repository it came from, a source URL, and a longer description. Wildcards can be given as in
- $ sudo yum info package
- List all packages, or just those installed, available or updates that have not yet been installed
- $ sudo yum list [installed | updates | available]
- Show information about package groups installed or available
- $ sudo yum grouplist [group1] [group2]
- $ sudo yum groupinfo group1 [group2]
- Show packages that contain a certain file name
- $ sudo yum provides
- as in
- $ sudo yum provides "/logrotate.conf"
- The "/" in the file name is required...
- $ sudo yum provides "/logrotate.conf"
- as in
- $ sudo yum provides
Verifying packages
Package verification requires installation of the yum-plugin-verify package so you might have to
$ sudo yum install yum-plugin-verify
Note this is a yum plugin, not an axecutable. There are many other plugins available for yum which extend the possible set of commands and arguments it can take
- To verify a package, giving the most information
- $ sudo yum verify [package]
- To mimic rpm -V exactly
- $ sudo yum verify-rpm [package]
- To list all differences including configuration files
- $ sudo yum verify-all [package]
With out arguments the above command will verify all packages installed on the system.
Installing/Removing/Upgrading Packages
- Install one or more packages from repositories, resolving and installing any necessary dependencies
- $ sudo yum install package1 [package2]
- Install from a local rpm
- $ sudo yum localinstall package-file
- Which is different than
- $ sudo rpm -i package-file
- Because it will attempt to resolve dependencies from remote repositories
- Which is different than
- $ sudo yum localinstall package-file
- Install a specific software group from a repository, resolving and installing any necessary dependencies for each package in the group
- $ sudo yum groupinstall group-name
- or
- $ sudo yum install @group-name
- $ sudo yum groupinstall group-name
- Remove packages from the system
- $ sudo yum remove package1 [package2]
- Yum will remove not only the package required but all packages that depend on them. This may not be what you want, so never run yum remove with the -y option, which assumes automatic confirmation of removal.
- $ sudo yum remove package1 [package2]
- Update a package from a repository
- $ sudo yum update [package]
- If no package name is given all packages will be updated
- $ sudo yum update [package]
During installation or update if a package has a configuration file which is updated, it will rename the old configuration file with a .rpmsave extension. If the old configuration still work with the new software, it will name the configuration file with a .rpmnew extension.
You can search for these filename extensions (almost always in the /etc subdirectory tree) to see if you need to do any reconciliation, by doing
$ sudo find /etc -name "*.rpm*"
This is the same behavior the more naked underlying rpm utility exhibits, but we mention it here for reference
Additional Commands
There is no shortage of additional capabilities for yum, according to what plugins are installed. You can list them all with:
$ sudo yum list "yum-plugin*"
In particular
- Show a list of enabled repositories
- $ sudo yum repolist
- Initiate an interactive shell in which to run multiple YUM commands
- $ sudo yum shell [text-file]
- Yum will read the command from that text file and execute them instead of from the terminal
- $ sudo yum shell [text-file]
- Download packages but do not install them, just store them under the /var/cache/yum directory, or another directory you can specify
- $ sudo yum install --downloadonly package
- In order to do this install the yum-plugin-downloadonly package. You can also then do
- $ sudo yumdownloader package
- This will download the latest version of package into the current working directory. Optionally one can calculate and download any dependencies as well
- $ sudo yumdownloader package
- View the history of yum commands, and possibly undo or redo a previous command
- $ sudo yum history