- Lab
- 
                        Libraries: If you want this lab, consider one of these libraries.
- Cloud
 
            
        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.
 
            
        Lab Info
Table of Contents
- 
                
                Challenge Assume That the YUM Metadata and Cache Are Out-Of-Date and Resolve the Issue so That We Can Update the SystemFirst, we'll clean the existing YUM metadata and cache, and create a fresh one: yum clean all yum makecacheNext, let's list the available updates: yum list updatesFinally, we need to update the software packages on the system: yum -y updateThis may take a little while, since we're downloading updates for everything currently installed on the system. 
- 
                
                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` StartsUse the yumcommand to search for any packages with apache or http in their names:yum search 'apache http'The Apache server comes with an httpdfile. Knowing this, we can useyumto find which package includes (provides) such a file:yum provides httpdNow that we know the name of the actual package we need to install, we can do it: yum -y install httpdUse the systemctlcommand to start thehttpd.service, and enable it to start when the system boots. This will do both:systemctl enable httpd --nowNow check the status of the httpd.service, and would should see active and running in the output:systemctl status httpd.service
- 
                
                Challenge Use rpm to Query for Configuration, Documentation, and Information about Which Package Owns /sbin/httpd, as Well as All Installed PackagesAfter installing a package like httpd, we can userpmto query for its configuration details, documentation, and other information. Usingrpm -qacan provide information about all the packages installed on the system.Let's look at any documentation files belonging to the package: rpm -qd httpdShow configuration files: rpm -qc httpdShow which package owns a file (in this case /sbin/httpd):rpm -qf /sbin/httpdShow all packages installed on the system: rpm -qa | wcWe 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 | tacAt 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*'
- 
                
                Challenge Query and Install the Elinks Package in the /tmp Directory, and Verify That Elinks Works by Browsing the Local WebsiteLet's first make sure that the elinkspackage isn't installed:rpm -q elinksNow we should make sure the development team did in fact download the correct elinkspackage:ls /tmp/elinks*.rpmUsing the rpmcommand, we can query thatelinkspackage and get some information about it:rpm -qp /tmp/elinks-0.12-0.37.pre6.el7.0.1.x86_64.rpmNow 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.rpmThis 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.rpmAlas, 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 yuminstead:yum localinstall /tmp/elinks-0.12-0.37.pre6.el7.0.1.x86_64.rpmAnswer y at the prompt. Finally, let's use the elinkscommand to make sure that the package installed correctly, and browse thehttp://localhostwebsite:elinks http://localhostIf we land at the CentOS Apache welcome page, we're all set. 
About the author
Real skill practice before real-world application
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.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.
 
           
                 
                