In this lesson,
we're going to discuss RPM and YUM packages.
RPM and YUM packages are important
because they're used to conduct Linux package management
inside of Red Hat-based distributions like CentOS.
Now, they're going to be used to install, patch,
and remove software packages on your Linux machine.
Now, these are some of the most common tasks
that you're going to do as a system administrator.
And because of this, it's really important
that you gain this essential skill
to understand how to manage your packages.
Different Linux distributions
will use different package management tools,
but if you're using Red Hat-based distributions,
like CentOS, you can use RPM or the Red Hat Package Manager
or you can use YUM or DNF,
which is the Yellowdog Updater, Modified or Dandified YUM.
Now, the RPM command is going to be used
to manage RPM packages on Red Hat-derived distributions.
It has options including -i and the package name
which you use to install the specified software package.
If you use -e and the package name,
this is going to be used to erase or uninstall the package.
v is going to be used to enable verbose mode
which gives you more details and error messages
if things go wrong.
h is going to be used to print hash marks
to indicate a progress bar
as you're installing the software.
And -V and the package name is going to be used
to verify the software components of the package
to ensure they exist.
To run the RPM command,
simply type in rpm, the options, and the package name.
Now, one of the most powerful features
of the RPM Package Manager
is the ability for it to maintain a database
of software information.
This database will enable you as an administrator
to discover the package version information,
to have a list of all the installed software,
to discover dependency information, and much more.
If you want to be able to query this database
and get information about it,
you can do that by typing in rpm -qa
to list all the installed software.
If you type in rpm -qi and the package name,
this'll list information about a single particular package.
And if you use rpm -qc and the package name,
this will list out all the configuration files
for a particular package.
Now, as I said,
RPM can also be used to validate and verify your software.
This verification will check to see
if the installed software components
are matching what the RPM package specifies
that should have been installed.
The verify option is going to be used
to troubleshoot installed software
and ensure that the entire software package is installed,
and valid, and working properly.
To do this,
you're going to use rpm -V and the package name.
Now part of the software lifecycle
is also to keep your software current
with the latest versions and updates.
RPM offers two primary ways for you to accomplish this goal.
The first is to use the -U option.
This will be used to upgrade the installed package
and then install the package if it's not already installed.
The second method is use the -F option.
This is known as the freshen option.
Now, when you freshen the installed package,
this is going to update the package if it's installed.
But, if it's not already installed,
it's not going to do anything
because you're just freshening an existing install.
So remember, if you use -U,
you will install the package if it doesn't already exist
or you'll upgrade the package if it does.
With -F, you will only upgrade the package if it exists.
The yum command is another way
that you can use package management.
The yum command improves on the functionality of RPM
while still using those RPM packages themself
and maintaining an RPM database.
This provides a more straightforward method
for you to manage your packages
and works as an upgraded version of RPM.
One of the biggest benefits of using yum is its ability
to automatically handle software dependencies.
This means that administrators can tell yum
to install a particular package
along with automatically installing
all the additional packages
that that thing depends upon.
An additional yum benefit is also the use of repositories.
Now repositories enable administrators
to more easily maintain version control over the software.
The yum command comes with lots of different sub commands
that you can use to manage your packages.
For example, if you type yum install and the package name,
this will install the package
from any configured repository.
If you use yum local install package name,
this will install the package from the local repository.
If you use yum remove package name,
this will uninstall your package.
If you use yum update package name,
this will update the package.
If you want to update all of your software,
you can do this by typing yum update and hitting enter
and this will update all of your installed packages.
Now note, if you do this,
it is going to download all the updates and install them
so this can actually take quite a bit of time.
If you type in yum info and the package name,
this will provide information
about the package that's installed.
And if you use yum provides file name,
this will provide a report of what the package provides
for specified files and libraries.
Essentially listing out everything that was installed
for that particular package.
If you want to run the yum command in general,
you're simply going to type in yum, the options,
the sub command and the package name.
Now, another thing you might use
inside of your yum is the -y option.
The -y option is going to automatically answer yes
to installing additional software dependencies
when you're trying to install a package.
If you don't do this,
yum is actually going to prompt you to answer yes or no
to each and every dependency that it wants to install
based on the software you asked.
Now, if you don't understand the concept of dependencies,
think about it this way.
If I wanted to create a new program,
there's lots of existing code that already exists out there.
So would I want to rewrite everything from scratch?
Well, probably not.
So instead, I can link to other libraries that exist.
For example, if you're used to using a Windows machine,
every single Windows software has the same basic features
where you can open a file or save a file.
It'd be kind of dumb
if everyone had to code that themselves.
So instead, there's a library you can call
that's called the file input output system, right?
And that way you can choose to just reference
the open dialogue box or the save dialogue box
using a single line of code
and everything else will be run by that library.
That now becomes a dependency.
And so when I go and give you my source code or my package
and you try to install it,
it now says in addition to installing Jason's new program,
I also need to install the file input output library
that was a dependency of Jason's program.
If you have to figure out
all those dependencies on your own,
it can be a nightmare,
but by using packages, you don't have to do that
because yum is going to find all those dependencies
and install them for you,
as long as you tell it to.
Finally, when it comes to RPM packages,
we can also use DNF as our package manager.
To install a package using DNF,
simply type in dnf install and the package name.
To uninstall a package using DNF,
simply type in dnf remove and the package name.
In general, most of the sub commands used by YUM
are going to also work in DNF
and if you want to learn more about DNF,
you can check the man pages
by typing man dnf and pressing enter
in your command line environment.