- Okay. In the previous video
you have learned how to use man, man is awesome.
As long as you know which command to use
but what are you going to do
if you don't know which command to use?
Well, then you are going to use the man DB.
The thing is that an index
of man pages is created in the man DB, the man database.
And you can use man minus K
or apropos to search the man DB on keywords.
In some cases you will get nothing appropriate.
If that happens.
If you are looking for something, not very common
then it may happen that there's just nothing matching
or you are looking for.
But it may also mean that your man DB is not updated.
And if that is the case, well, you need to update it.
Sudo, man, DB is what you are going to use.
Let me demonstrate.
(keyboard typing)
All right.
I am typing man
minus K man, minus K or apropos it's the same.
So you decide what you want to use.
I'm using man minus K user and oh no
I am getting nothing appropriate.
That is definitely not good.
But it's something that may happen
on newly installed systems.
So how come isn't this taken care
of when installing the system? Well actually no.
The thing is that the man DB is generated
by a scheduled job, a Cron job, as you call it in Linux.
And this Cron job runs every, every day, once a day.
And this system was installed not so very long ago.
So this is a brand new system
and that means that the Cron job has
just not been started yet.
And you know what
I'm going to show you? man
so that we can actually practice using man and
and find out how to use man minus K.
So man, man, and I'm going to search
for minus K so slash minus K.
Look at the lower left corner
slash minus K is bringing me
to the first and the second occurrence.
That's not what I need.
So I'm pressing N to get to the next and N again and there
We can see equivalent
to apropos search the short manual descriptions
see apropos for details.
So we are in the wrong spot and I need to use man
on apropos to get the appropriate information.
And there we get an explanation
and we can see the database searched
by apropos is updated by the man DB program.
So man DB program, and it's also telling us this may be run
by a periodic Cron job.
That's exactly what was happening
but how do we deal with this man DB?
Well, man, should know, man, man DB, there we go.
And man DB always do a quick check.
If you're in the right section
if you see a one or an eight, then you are good.
If you see a three or something else that is not a one
or an eight, then are probably in the wrong location.
So what do we see?
We see that man DB comes from section eight
section eight means that it's an admin command.
And that means
(keyboard typing)
that if I want to regenerate the man DB just
typing man DB is not going to work.
As you can see, I'm getting warning cannot create
and more warning cannot create, cannot create.
That means that we have a permission issue.
So I'm going to repeat this command.
I look at my command line.
I have my cursor blinking at the end of the line.
I'm using control A
control a brings your cursor to the start of the line
and control E to the end of the line.
But I need to be at the start
of the line because I want to type sudo in front of it.
And of course you can remove this command and try again
but it's so much more convenient.
If you can just move your cursor
to the start of the line, I'm using sudo.
And in order to do sudo, I need my password.
There we go.
And now it is updating the man DB.
Even if it's doing the right thing
you do see a couple of field messages.
Please ignore the field messages.
What you should be looking
for is the third line from the bottom.
Almost 8,000 manual pages were edited and the result is
that right now I can use man minus K user.
And oh boy, did you see that?
This is what I call too much output.
Sometimes on Linux, you get too much output
and I will tell you in much more detail
what we are going to do later
but now I'm going to give you a quick look ahead.
If you get so much output, use a pipe, the pipe
will take the result of the first command and use it
as input for the second command.
And you have two options, man, minus K user pipe, less
which will, which will send it to the less pager.
And in this pager, you can watch the results screen
by screen, use a space bar to move forward.
But Hey, this is still too much reading.
Maybe you wanna do something smarter.
If we repeat the output of man minus K,
Then you can see that in the first column
there is the section behind all of the commands
and we are going to use this section number to
find the command that we need.
Now, what is the thing?
If I'm looking for users and probably I'm looking
for something like I wanna create a user
and what do you think, can you create a user
without using sudo? Of course not creating user
requires root privileges.
And that means that the command that I'm looking
for most likely is documented in section eight.
(typing)
So I'm going to pipe this time, the output
of man minus K user to the grep command.
He grep command is also one of these commands
that we will explore in much more detail later.
But for now you should know that the grep command is one of
The most useful commands in Linux.
It's a filtering utility and
by piping the output to grep eight man minus K
user is only going to show these lines that contain an eight
and there near the bottom
you can see user add and user del and user mod.
And in case you are wondering why doesn't man
minus K have an option to work with specific
specific sections of man.
Well, that is because
of something that we call the Linux philosophy.
In the Linux philosophy
It's very common not to program all the functionality
in one command
because that would make one big bloated command.
You wanna make sure that you pipe the output of one command
to another command, which is a smart combination
of commands to get you exactly the result that you wanna do.
So this is why we are using pipes a lot
in Linux to combine functionality.
And by the time you are done with this course
you will know how to do it
Exactly.