Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon

Managing Packages on RedHat/CentOS Systems

Updating, installing, removing and querying packages are core skills for anyone managing Linux distributions. Some of the most popular package management tools include the `yum` and `rpm` tools included in the Red Hat/CentOS Linux distributions. During this activity, you will work with the Red Hat/CentOS high-level package command `yum` for updating, installing and removing packages, since it automatically manages packages required for dependencies. You will also use the Red Hat/CentOS low-level package command `rpm` to query information about installed packages. After completing this activity, you should know how to properly manage software packages on Red Hat/CentOS systems.

Google Cloud Platform icon

Path Info

Clock icon Beginner
Clock icon 30m
Clock icon Jan 17, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Assume That the YUM Metadata and Cache Are Out-Of-Date and Resolve the Issue so That We Can Update the System

    First, we'll clean the existing YUM metadata and cache, and create a fresh one:

    yum clean all
    yum makecache

    Next, let's list the available updates:

    yum list updates

    Finally, we need to update the software packages on the system:

    yum -y update

    This may take a little while, since we're downloading updates for everything currently installed on the system.

  2. Challenge

    Use yum to Search for the Apache HTTP Package, Find What Provides /sbin/httpd, Install the Correct Package for the `httpd` Service, and Then Use the systemctl Command to Make Sure the `httpd.service` Starts

    Use the yum command to search for any packages with apache or http in their names:

    yum search 'apache http'

    The Apache server comes with an httpd file. Knowing this, we can use yum to find which package includes (provides) such a file:

    yum provides httpd

    Now that we know the name of the actual package we need to install, we can do it:

    yum -y install httpd

    Use the systemctl command to start the httpd.service, and enable it to start when the system boots. This will do both:

    systemctl enable httpd --now

    Now check the status of the httpd.service, and would should see active and running in the output:

    systemctl status httpd.service
  3. Challenge

    Use rpm to Query for Configuration, Documentation, and Information about Which Package Owns /sbin/httpd, as Well as All Installed Packages

    After installing a package like httpd, we can use rpm to query for its configuration details, documentation, and other information. Using rpm -qa can provide information about all the packages installed on the system.

    Let's look at any documentation files belonging to the package:

    rpm -qd httpd

    Show configuration files:

    rpm -qc httpd

    Show which package owns a file (in this case /sbin/httpd):

    rpm -qf /sbin/httpd

    Show all packages installed on the system:

    rpm -qa | wc

    We piped this command into wc, just so our screen wouldn't be inundated with information, but we can see that there are several hundred packages installed on the system. To look at them in order of install time, from oldest to newest:

    rpm -qa --last | tac

    At least this way, what's down near our new command prompt is the most recently installed packages.

    Now if we just want to see packages that start with httpd, we'd run:

    rpm -qa 'httpd*'
  4. Challenge

    Query and Install the Elinks Package in the /tmp Directory, and Verify That Elinks Works by Browsing the Local Website

    Let's first make sure that the elinks package isn't installed:

    rpm -q elinks

    Now we should make sure the development team did in fact download the correct elinks package:

    ls /tmp/elinks*.rpm

    Using the rpm command, we can query that elinks package and get some information about it:

    rpm -qp /tmp/elinks-0.12-0.37.pre6.el7.0.1.x86_64.rpm

    Now let's see what scripts will execute when the package is installed:

    rpm -qp --scripts /tmp/elinks-0.12-0.37.pre6.el7.0.1.x86_64.rpm

    This is good information to have. If the package files are potentially not from a trusted source, we're going to want to know what scripts will run during the install process, and what they do.

    We can try to install the package with this:

    rpm -ivh /tmp/elinks-0.12-0.37.pre6.el7.0.1.x86_64.rpm

    Alas, we will probably have unmet dependencies. And when we try to install the packages in these error messages, we may find that those have unmet dependencies. It can be a mess. Let's try this with yum instead:

    yum localinstall /tmp/elinks-0.12-0.37.pre6.el7.0.1.x86_64.rpm

    Answer y at the prompt.

    Finally, let's use the elinks command to make sure that the package installed correctly, and browse the http://localhost website:

    elinks http://localhost

    If we land at the CentOS Apache welcome page, we're all set.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans