The 'man' command is used to read the man pages (or manual pages). It's basically an interface to read the instruction manuals for specific commands.
- Display the man page for a specific command: man command
- Display the man page for a command from a specific section (ex: section 7): man 7 command
- Lookup man pages referenced by 'command' and print a short description: man -f command (SAME AS: whatis command)
- Open the man page for a command in a browser: man --html=browser_name command - Open the man page for a command in a browser using $BROWSER variable if set: man --html=$BROWSER command - Display the location of a man page rather than the man page itself: man -w command
- Search for man pages containing a search string: man -k "string"
- Display the man page using a specific locale (such as 'us' or 'de', etc.): man --locale locale command
- Specify which PAGER you want to use to view a man page: man -P less command (uses 'less' as the PAGER) man -P more command (uses 'more' as the PAGER) man -P 'nvim +Man!' command (uses 'nvim' as the PAGER)
Your support is very much appreciated. Thanks, guys!
If you want to learn more about all the various commands on a Linux system,
probably the best resource available to you are what are known as man pages. Now, what are man
pages? Man pages are manual pages. They're the instruction manuals for the commands on your
Linux system. The way man works is you run man and then name of command to get the man page or
the instruction manual. For example, if I didn't know how the ls command worked, I would run man
space ls and now I get the man page, the manual for the ls command, which is the list command
q to quit out of the man page. Now, there are many, many thousands and thousands of man pages
on your system. It's a gigantic database of man pages and they're broken into sections. If you
read the man page for the man command, so run man on man to read the man man page, they tell you
about the sections, the main sections that the man pages are broken into. They are broken into
nine different sections, basically from section one, which are your executable programs and shell
commands all the way up until section nine, which are kernel routines. And you can actually see
where these are located on the system. If I do an ls of slash user share man and just go ahead and
hit enter. We have a lot of man pages in various languages, but if I scroll up, these are actually
your main man sections, you know, man one, one P two, three, three P four, five, six, seven, eight.
I don't have a section nine. So these are the directories where the man pages actually live
on your system. Let me go ahead and clear the screen. And it's very important to know about
the sections because sometimes there will be a command that is in two different man page sections.
For example, if you run this command here, man dash F and I give it a name of a command, let's do
the ls command. As an example, dash F basically finds every reference of ls in the man page
database, and it will tell us which section it's in. So you can see ls is actually in two different
sections, one and one P. If I want to read specifically the ls man page in section one,
I would do man one ls to read that, or I could do man one P ls to read that particular man page.
By the way, there is an alias for man dash F command. Instead of doing man dash F,
you could also do what is that also works. And I can actually verify that by doing what is
ls. And you can see it is the same output as man dash F. Now, one of the coolest commands
that you can do with man, and I don't think most people know about this is you can actually open
a man page in a web browser. If you would prefer to read it that way, you can do man
dash dash html and then equals some browser name. For example, if I want to use brave,
I have brave installed on my system. I want to read the man page for let's do CP the copy command.
And I run that it just opened my browser on a different monitor. Let me show you guys.
It just opened this and you can see this is the man page for CP, except it converted it to html.
And now I can read it inside my browser. If you happen to have the browser variable
on your system, for example, on my system, I have the browser environment variable set to
the Firefox browser. If you happen to have something like that and want to use it,
you could actually use man dash dash html equals dollar sign browser. If that variable happens to
be set a couple of other flags that are kind of useful man dash W for where you could do this.
And instead of reading the man page, it will actually give you the actual path to the man
page itself. If you want to search for a man page containing a certain string, do man dash K and then
do a string such as install, for example, just picking a word out of the air. And that returns
all of the man pages that in their name or their description, they had the string install
somewhere. And you can see there's a bunch of them that had that particular string.
Finally, one last thing you can do. Most man pages are just going to default to English,
but there are some non English man pages also in the database. So if you want to specify a specific
locale, you can do dash dash locale and then whatever locale you're wanting and then the
command. So the man page that you actually want to get, for example, if I wanted to do the German
man page for LS, I could do dash dash locale D E L S, for example. And in this case, the man page
is actually in English. Although I did notice that I do have some German language down here
in the kind of like a system bar here on the man page. If I up arrow and did something different,
maybe the German man page for man page, right? So dash dash locale D E man. Now I get some German
text here. Not every language is going to have a man page for every command. So most things
obviously are going to have English available, but you may have some other things available as well.
One final thing I should mention is that when you read a man page by default, the pager,
the program that is reading the man page, we call it a pager by default. It usually uses the less
command, but you can specify a different pager. If you want, you could use the more command.
What I'm actually using as my man page reader is actually NeoVim. And the way you specify this,
you could do man dash capital P for pager and specify a pager. For example, if I wanted to
specify less as the pager, and maybe I want to read the man page for MV, the move command,
you can see now I'm using the less command for the pager rather than NeoVim. If you would prefer
the more command, you just dash capital P more, and then name of command. And if you prefer to do
like me and use NeoVim, what you could do is you could do dash capital P. And then inside quotes,
what you need to do is you need to do nvim space plus capital M, lowercase a n exclamation point,
and then name of command. And now you're using NeoVim as your man page reader. Now, because I
always want my man page reader to be NeoVim, rather than less, what I've done is I've added
a line and all of my shell config. So I've added things to my bash RC, my ZSH RC, and my fish
config. So no matter what shell I'm in, I have NeoVim as my man page reader. So if I go into my
bash RC, for example, and I scroll down, I have a line where I have man pager. So that's the variable
you need to set. And what I've done is I export man pager to nvim plus man exclamation point.
That way, I don't have to specify that every time I run a man page, as long as that's in my bash RC.
And if I'm using bash, every time I run man on any command, it will run that using nvim as my man
page reader. If you want to learn more about the man command specifically, run man on man in the
terminal and read the man page. It's not very lengthy. There's not a ton of flags and options
with man. I've already shown you most of what you can do with it here on camera.