2. Package Management
• Software is the basis of any operating system, allowing you to install and
use different utilities.
• In Linux, software is distributed through the use of packages, which
contain the actual software files.
• Each distribution of Linux has its own package management system.
• For Red Hat, there are two package management systems: RPM and Yum
2
3. Working with RPM
• A package contains a directory structure that is composed of files to make up
the software application.
• In Red Hat, packages have the .rpm extension and can be installed through
different means.
3
4. Naming Convention RPM
• Package Syntax: package_name-version-release.arch.rpm
• As an example, let’s look at the postfix package, which is used to install an SMTP
mail server:
• postfix-2.6.6-2.el6.x86_64.rpm
• Name of this package is postfix, the version number is 2.6.6, and it is meant for a
64-bit operating system.
• The -2 is the release, and the el6 is something you find only in Red Hat packages
because it specifies an internal version number for the Red Hat release.
4
5. Package Dependency
• Sometimes for an installation it requires to install another as well; this is known
as a dependency.
• Certain packages require certain versions to make sure that their dependencies
don’t break when upgrading.
• You can see why being able to get version information from packages is a
necessary skill.
• All packages are held within a repository somewhere, depending on who
produces the package.
• Red Hat has its own software repositories, which hold the packages for the Red
Hat operating system.
5
6. Installing and Removing Packages
• RPM is the utility is used to manage individual packages outside the repositories.
• Used to install .rpm packages that are downloaded (either manually from the
repositories or the Web).
• Syntax: rpm [options]
6
7. RPM Options 7
The options for rpm are divided into three different sections
(modes): install/upgrade/erase, query, and verify.
9. Downloading an RPM 9
To download something from the command line, use the wget
command.
Step 1. Download the nano package from the Web:
# wget http://www.nano-editor.org/dist/v2.2/RPMS/nano-2.2.6-
1.x86_64.rpm
Step 2. When the download is finished, the package is in the present
working directory.
Install it with the rpm command:
# rpm -ivh nano-2.2.6-1.x86_64.rpm
11. Upgrade and Delete an RPM
• To upgrade the package, if the package isn’t already installed:
• # rpm -Uvh nano-2.2.6-1.x86_64.rpm
• To delete an installed package, use the -e option to remove it:
• # rpm -e nano
• You can always reinstall the package at a later date if you keep the .rpm
file on your system (or you can always download it again).
11
12. Querying and Verifying Packages
• Query the installed system packages
• # rpm -qa | grep [package name]
• Query the installed system packages for nano:
• # rpm -qa | grep nano
12
13. man pages
• There is usually a documentation for a given package. This documentation is
known as a package’s man pages, and most packages come with them.
• To access the man pages, use the man command:
• # man nano
• Scroll up and down to view the documentation and press q to quit.
• man pages provide in-depth details, usage, and examples for any given
package.
13
14. YUM (Yellow dog Update Modifier)
• The yum command has access to repositories where tons of
packages are kept and can install, upgrade, or remove them for you
automatically.
• Yum also takes care of resolving and installing any dependencies for
you, which the rpm command can’t do
14
15. Syntax: yum [options] command
•Options:
• -c Specifies the location of the config file
• -q Specifies quiet, no output
• -y Indicates to always answer yes to prompts
• -v Provides verbose output
15
16. Commands
• clean Removes cached data
• erase Removes a package from the system
• grouplist Displays available package groups
• groupinstall Installs the packages within a group
• Info Displays information about a package
• install Installs a package on the system
• search Enables you to search for a package
• update Updates a package
16
17. Installing and Removing Packages
• Directly from the Red Hat repositories:
• # yum install -y postfix
• You could also update the postfix package. Just change the
command from install to update:
• # yum update -y postfix
• Use remove here because you don’t want anything lingering
around at the moment:
• # yum remove -y postfix
• One great feature about yum is that instead of updating a single
package, you can list all updates that need to be installed for the
system:
• # yum list updates
17
18. YUM Commands
• From this list, you can choose to update packages individually or as
a whole. If you want to install all the updates, you can use the
following:
• # yum update
• Keeps a list of “groups” that contain a set of packages, making it
easier to install sets of packages together.
• The most common example would be if you wanted to install an X
server package so that your system has a GUI. You can use the
grouplist command to get a listing of all available “groups”:
• # yum grouplist
18
19. Searching for Packages
• Gives you access to the repositories from which you can install
software
• Use the search command to query software packages from the
repositories.
• Find the postfix package to install:
• # yum search postfix
• To find out more information about the postfix package, use the
following command:
• # yum info postfix
19
20. Clean Command
• One additional command that you can use with yum (rpm
doesn’t have an equivalent option) is the clean
command.
• It wipes the yum cache and forces it to sync with the Red
Hat repositories, giving you the most updated package
information.
• To flush the cache, do the following:
• # yum clean all
20
21. Configuring Additional Repositories
• Sometimes you might want to install a package that isn’t in the
repositories that come preconfigured with Red Hat.
• If the package is available in someone else’s repository, you can
add that person’s repository to your yum config file.
• You can either add your own custom repositories to the main
config file /etc/yum.conf or create a .repo file in the
/etc/yum.repos.d directory, which will be added automatically.
21
22. Configuring Additional Repositories
• Here is what a sample entry for a custom repository looks like:
[unique title]
name=My Custom Yum Repository
baseurl=ftp://rhel01/opt/yum/myrepos
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-
redhat-release
• This entry defines a name, a location, and whether or not the repository is
enabled.
• You can save this entry as a test.repo file in /etc/yum.repos.d, and you will
have access to any of the packages in the /opt/yum/myrepos repository on the
RHEL01 system.
22