So when working with Linux, sometimes you may have a hard time finding which man page to use.
Now what are you going to do?
Well, you are going to use the fact that normally you have an index of man pages in the mandb.
And this mandb is a database with a short description of all the man pages.
You can use man K, which is the same as the apropos command to search the mandb on keywords.
In case you are searching for something very obvious and MAND is giving
you nothing appropriate, then you need to generate the mandb using sudo mandb.
In case you are wondering why. Well, normally the mandb is a scheduled job and these scheduled jobs don't run all the time.
They run typically once a day. And on a freshly installed system
you may find that the MANDB has not yet been generated.
Let's go check this out.
Let me start by using Man k user and then what do
we see? Oh my goodness, we see a lot of results.
We see so many results that I need to filter down a little bit and I need
to think about what do I really want to do. Well, let's assume that I'm looking for
the command to create user. Then I want man k user. But I only want to see
commands from section 8 because section 8 is where you would normally find administrator commands.
Creating a user sounds like an administrator task, now doesn't it?
In order to filter out only the results from Section 8, I'm going to send the
output of the man k user command to be used as input for the grep command.
Grep is an amazing command that allows you to filter output. And I'm going to grab for
eight As a result, I will only see lines that have an 8 in the result.
There we can see that the line is a little bit more readable.
User ad from section 8.
That is what we probably need to do next. Obviously you can use
man on user ad to read all the information about user ad.
Let me use Q because I want to show you one more thing that is Man
K sender Sander is my first name and oh boy, I'm getting a nothing appropriate.
Now this is the nothing appropriate that I want you to be aware of.
What can you do if that is happening? Well, I would say let's check out the man page for man
to figure out more about man minus K so that you can learn what maybe we had to do.
And here we can see the synopsis and all different use cases for man K. You
also see a list of all the different sections in Man, I haven't talked about all
of them because for now section 1, 5 and 8 are the only ones that matter.
And then Am I really going to scroll down? No, I'm not going to scroll down. I am
going to search for the option K. So I'm using forward slash K and I'm pressing enter.
And look at that man K print F searches for short
descriptions. That's exactly what I need. And that's equivalent to apropos.
That means that I can use Q2 get out and use man apropos to get the man page for apropos.
There we can see that it is updated by the mandb command. Now if you need to know how
to do it, then next man on mandb and there we can see mandb is coming from section eight.
Now I don't really have to use it because my mandb is working perfectly. All right,
but in case you do have to use it, type MANDB and see what happens.
Oh boy, this is what happens. I'm getting permission denied all over.
And you know why? That's because mandb is in section 8
and commands in section 8 typically need super user privileges.
So that will be sudo mandb.
Then I need to enter my password and there we can see that MandB is generated. Again, nothing
new added. That's totally obvious because we just started with this system and nothing has changed yet.