[No audio]
Okay, guys, so in this lesson, we are
going to cover advanced package
management. We have the package in our
environment, we installed it, we learned
those couple of commands earlier, and
one is yum, and the other one is rpm.
Now rpm is a Redhat package management
command. There are other commands that
are used in other Linux distribution
like apt get for Ubuntu and many other
different flavors. But anyway, our focus
is on CentOS and Redhat. So we will be
using rpm and yum command. So what
exactly we are going to do in advance
package management? Well in advance
package management we will learn how we
could install packages. Hey, you could
do that through yum command, right?
Yeah, of course, we could do that.
That's the best way to do the
installation of the packages. What if
you already have the package and you
just want install it, so that part will
cover. Then we'll learn how we could do
the upgrade of those packages, followed
by how we could delete those packages.
Then we'll see how we could view a
package detail. Meaning if you have an
installed package, and you want to know
more information about the package, how
or when it was installed, what that is
packages about, when it was built, what
are the configuration file associated
with it, and a lot of other information
related to the package. Then also
identify the source or location
information. If you have a file, or if
you're running a command, let's say you
run a command pwd or ls, you want to
know which package that command belongs
to, so that type of information will
cover. So and last one is the package
configuration file. So if you have
installed a package, let's call it ABC.
So we all know that all the package
configuration files are by default in
/etc. So once the package is
installed, and configuration files get
created in etc, but then it goes into
subdirectories. So etc slash this
slash that, that we don't know, so sometimes
we even forget. So how can we find out
that information about a package, if you
are, if you have done the download,
installation, and now it's about the
configuration of that package. So those
are the things that we'll cover. So, to
go over one, a one by one, all those
things, I'm going to go ahead and log
into our Linux machine. I'm gonna use
our PuTTY session to SSH into the Linux
machine. So let's go into our Linux
machine right here. I have already
logged in and I am logged in as root.
And you could also verify by looking at
this pound sign. Okay, so the package
that we are going to install in this
lesson or in this practice is KornShell
package. Now KornShell is a shell,
which you probably have already know
about. It's just like a bash, or C
shell. So I'm picking this just for
practice purposes for just for this
lesson. So KornShell is the package
that we do not have in the system, and
we are going to install, it needed to be
upgraded, deleted, view its package
information. And we will cover
everything that we have listed on on
this lesson. So let's see if we have a
KornShell package already installed in
the system. So to check that you will
have to do rpm -qa grep it for ksh.
And you'll see we do not have
that package installed in our system. So
now we have to install package through
two ways. One is that we run yum
install the name of the package. The
second one is that we download the
package through a different means, if you
do not have internet access, then you
could download the package then install
it. But I do have internet access on
this machine. And I can verify it by
doing ping www. let's say
facebook.com. And you will see I'll get
a response back see. It means that I am
online so you could also check by
running ifconfig command and you'll see
I have IP 192.168.1.13. You probably
have a different IP, depends on which
network you are in. Anyway, so I do have
it in an axis and I don't need to
download a package. So I could what I
could do is simply do is yum install ksh,
KornShell. Anything that is related
to KornShell I could just put it
asterisk, so hit
enter. Okay, and you will see it did find
a package, one package and the name of
the package and it says x86_64 package, it
doesn't have any dependencies good. So
I'll go ahead, hit Y. Also, if you notice
the bottom tells you the size of the
package, installed size. You could
confirm everything before you go ahead
and hit Y. So hit enter, and this is
going to download the package first. And
then once the package is downloaded,
then it will go ahead and install the
package, verify it, and clean it up. So let's
give it a few seconds and let it finish.
[No audio]
The package installation has been
completed, and it is successful. Once you
see at the bottom it says CompleteQ. Now
how do we verify it, hit up arrow key
again, and you will see you will have
that package last run rpm -qa grep for
ksh, hit enter. And this is the
package that was installed during our
yum install command. Okay, so now what
if you wanted to remove that package,
you could simply run the same command
yum remove ksh and hit asterisk,
and hit enter. This is going to go ahead
and remove the package that it just
installed, hit y, and it is completed. Now
run the pack the rpm command again to
query their database and the list of
package that installed, and you will see
there is nothing installed that
matches KornShell. Okay, so that is the
first and most preferred way to install
and, download and install a package. Now
coming back to the same scenario, what
if you do not have internet access? Or
what if you do not have a local
repositories? Then what do you have to
do is, you have to go, you have to know
the exact location where the file, of how
to download a file and then do rpm
command to install the package. But
first, let's go to our internet and go
to Google, if you have a different one
different search method, web server that
you could use, you could use bing or
whichever. Anyway, so I'll type in as you
can see, I already have typed in before,
download ksh for centos 7. So
hit enter and go and click on the first link.
[No audio]
This will bring you to the pkgs.org page,
come down, and all the way down,
and you see where it says the package
that ends with .rpm, just simply right
click to it and click on Copy link
address. Once you did the Copy link
address, go back to your Linux machine,
and now this time type wget and the
package exact location of the package,
and hit enter. Now you're probably
thinking hey, I don't have internet
access and how can I download this
package if I don't. Well, the simple way
is you could go ahead and download on
your machine on the machine that already
has internet connection you download and
then you get FTP or whichever way is
preferred for you that you could FTP over.
It has downloaded. Where did it download?
Let's check, pwd, it's downloaded in slash
root. Let's verify it, if it is there by
doing ls -ltr, hit enter, and you
will see this is the package rpm. Now we
have installed this package before using
the command yum. But now this time we
are going to install this package using
the command rpm dash hiv and the name
of the package. The hiv, other
different options you could use hiv
differently, vi hiv, ivh, whichever the way
you prefer, I prefer this way. So go
ahead and hit enter, and now it has
installed that package. And now you
could check by running rpm -qa
and grep for ksh, and you will see
the packages there. Right. So that is
the way you could install that package.
Now what if you wanted to verify the
information about the package. You could
do rpm -qi, i as an information,
and the name of the package. Copy, right
click, hit enter,
and you will see the information about
the package. The package name is KornShell,
version, release, architecture,
installed, the group, and a whole bunch of
information, where you get it, what
exactly it does, what's the information about. So
this is about the information of that
specific package that has been installed
in your system. Okay, so next step is
what, how can you delete the package
using rpm command. Remember, we learned
how to delete a package using yum
remove command. Now let's delete a
package using rpm. For that, you need to
know exactly the name of the
package. So the name of the package we
have it by getting running the command
rpm -qa. Now run rpm -d as
for delete, specify the entire package
name, hit enter. And now it has
deleted that package. Verify it by doing rpm
dash qa and grep for ksh. And you
see it has removed a package. Okay, so
now this was about removing the package.
Now I want to cover more things about
this package. So I'll go ahead and
install it again. This time I'll install
it with yum install ksh*,
[No audio]
this package, and it has installed that
package, perfect. Again, verify it. Yes,
that package is there. Now, I need to
list configuration file of this package,
is how can I list that. So you could do
rpm -qc, and the name of
the package. Hit enter, and you will see
the configuration file that you need to
modify in case you might need to do the
some configuration of the package, and
these are the list of all the
configuration file. Remember I told you
the package configuration file are
always in etc directory. But then
once you are in etcdirectory, there are
1000s of files, 1000s of directories,
where do we have to go exactly for that
specific package? Well there for that
you have to find out the configuration
file. And how do you find out? I just
showed you rpm -qc. Now what if you
want to find out some information of the
command, let's say if there's a command
associated with this package, and the
command for that package is I know
offhand is ksh, just hit enter
and that will bring you to a KornShell.
Just like a regular command like pwd, ls
command, every package has a command
associated with it. So let's exit out so
we could go back to our bash shell. So
this is a command, and what if you want
to know which package this command
belongs to. For that you have to run the
command rpm -qf, and ksh. Oops,
sorry, I forgot. First I need to know
the path of that package, of that
command. So I'll do which ksh. And
it's telling me that key sh command. The
full path is /usr/bin/ksh. Now I
could do that command, rpm dash qf, and
I'll put that here, hit enter. And now
it's telling me hey, this command that
you run, this command belongs to this
package. Good. Good. Now, you probably
thinking, hey, this is fun, I could find
out all the package information for all
the commands I have ran. Right so far,
whatever the commands that you have
learned, you could definitely find out
which package it belongs to. For
example, my favorite command is let's
say every time you log in a way to see
who is logged in or which directory I'm
in. So let's say pwd is the directory,
right? That's the command
which tells you which directory you are
in. So if you wanted to know which
package this command belongs to, first
what do you need to do, you need to find
out the command path, so which pwd. Now
you know that this command, the full path
for this command is /usr/bin/pwd. Now,
[No audio]
do rpm -qf /usr/bin/pwd,
and it is telling you that this
command pwd belongs to a package called
coreutils. And then version, if you
remove this package, then you cannot run
the command pwd, then whichever you are
in how you're going to find out? You
cannot find out, so you would have to re
install that package again using yum
command or going to the link and
downloading. So that's how you actually
find out the information about a specific
package, a specific configuration of
package, or the package information of a
command. Package management is one of
the things that everyone would face in
their career at least twice a year or
three times a year when you have to do
or install or upgrade the packages.
Hopefully this lesson serves a purpose.
If you have any questions always send me an email.