Getting Help from Linux - Part 1 Man Pages

Oooh, I just know I'm going to hear it in the comments for that one.
But you know what? Just how many of you have tried something similar with other words? You know you have at least once or twice. Go ahead, try one or two..you might be surprised. So
why an article on man pages? Well, it's not just man pages, it's more like how
to get information from Linux. Sure, you can use the internet and search for
your problem, but you can also use the tried and true manual pages (or info)
that comes with Linux distros out there. This and my next blog post aim to
cover both Man pages and Info pages. Not only will you learn a thing or two
about each one "- and, probably more than you ever wanted to know about each -"
but the differences between the two as well. Granted if you just want basic
syntax information about a command, there is always the tried and true: --help,
-h or -?.

So just why would you use Man and Info over using your internet browser? Well,
for some of us out there, servers are console only and can also have restricted
(depending on your infrastructure) internet access. Being able to reference a
Man or Info page straight from a console is a very quick and easy way to pull
up information on a command-line argument, or what a specific command does, or
what's in a configuration file. The argument could be made that there are
websites that replicate Man pages, with hyper links to other Man pages. But
are they the correct pages for your distro and version? The best way, in my
opinion, is to use the pages that were installed with the packages that you
are currently using with your distribution. Keep in mind though, the Man
utility might not have been installed with your various flavor of Linux at the
time you installed it. But most supported Linux distributions that I have come
across in the wild do contain Man packages that can be installed (man-db and
manpages come to mind for the necessary packages for Debian based systems).

Now what's this about Man and Info? I'll step up on my soapbox here for a
second, and once again I'm sure to see a comment (or 10) about how one is
better than the other. Personally I have always preferred Man pages, they have
been around since as long as I've been messing around with Unix and Linux
(90's) and of course around much longer than that. Info was created by the FSF
(Free Software Foundation) as a hypertext document with more in-depth
information than you will find in Man pages. Why two of them you ask? I have
no clue, you would have to ask the FSF about that. It can be really confusing
when you 'man sed' and read the short information stored in sed's Man page,
then 'info sed' and find a lot more information stored in the Info pages. I
found that Gnu utilities have very in-depth Info pages, but other command line
utilities are just Man pages read into Info. If I need further information
than what my Man page tells me, then I'll see if Info has it. In a nutshell
though, the purpose of either utility is to make it easier for the end user to
get information from Linux.

Because there is so much information out there in Man pages and Info, and such
little space in a blog post, I will be splitting these up into two parts. Part
one will be on Man pages and the second part will be on Info.

Man Pages

As I said earlier, Man pages have been around for quite a while. They were
designed as a way for people to reference help (manual) pages on a system. A
programmer/engineer/etc who created a utility was (and still is) expected to
create a Man page that follows a certain page layout so that others can
reference relevant information about the topic at hand. This is just my 2c,
but I don't believe that because Info is around, Man pages are going to go
away. They have become the heart and soul of the Linux/Unix infrastructure
when it comes to referencing utility information. With that being said, let's
get our learn on.

Man Page Layout and Navigation

What I do like about Man pages is that most of the time they're laid out the
same. Call it military discipline, or a touch of OCD, whatever you prefer. I
say most of the time because there are the select few that will change around
one or two things in the order but they usually have the 9 main topics in the
Man page. This is how they break down:

Name

- This is the name of the subject of the page..usually has a number in
parentheses that denote the manual section. That number relates to the these
sections:
Man Page Sections

User Commands

System Calls

Library Calls

Special Files

File Formats

Games

Miscellaneous

System Administration

Kernel Routines

Synopsis

- A brief summary of the subject of the documentation

Description

- Self explanatory, more in-depth description of the subject and what it does

Options

- Explanation of execution options, command line arguments and what each one does

Files

- This section lists various files that relate to the topic, such as configuration files

Navigation

The Man utility uses Less to display help pages. What this means is if you're
familiar with Less, you shouldn't have a problem with Man. For those of you
that are not familiar with Less, or its better known cousin More, than here is
your quick crash course in Man page navigation. Once you open up a Man page,
you can navigate up/down a single line with either the up/down key or press
<enter> to go down 1 Line. To go Up/Down an entire page you can use the
PgUp/PgDn Keys, Space Bar, or D Key for Down (B Key for Up). If you are
looking for a specific word or phrase in the Man page, type '/' and enter your
phrase to search the Man page. The letter 'n' will search for the next word in
that phrase. The '/' character will also search the page for the last
previously searched phrase. And there you have it, basic navigation. I've
provided a quick cheat sheet below.

Tips and Tricks

Here are some basic tips and tricks for using Man pages, from searching Man
pages to printing Man pages and everything in-between. Don't feel bad if you
get lost, there's a manpage for Man!

Search

Have you ever had that problem where you just know there's a manpage for a
certain keyword but you can't remember the manpage itself? By using man -k
<keyword> Man will search through its list of manpages for that specific
keyword and list all manpages that reference it. For example:

From here I can see all the manpages with the word 'sleep' in them. Earlier in
this article I described the various sections of the man database, the results
for -k shows those section numbers. Because of this, we know that there are
two sleep pages, one that is a user command and another that is a library call.
By just typing 'man sleep' odds are you will end up with the user commands when
you really wanted the library calls. By knowing the correction section, you
can now type: man 3 sleep and pull up the manual page for the
sleep() library call. On the same token, if you know the command you are
looking for but feel that there are more than one Man page for the command, use
the -f flag: man -f <command> will list the command with the sections in parenthesis. As stated earlier, typing man section <command> will bring you to the specific section you want to reference.

Printing and Display

So what do you do if you want to print the Man page for reference? And just
who does that? Well, I frequently print off Man pages and reference them from
time to time when I am not near a terminal, maybe that's the techie in me (or
the blogger). I tend to print off the Man pages that I need when I'm writing
articles so that I have them close at hand, especially if I know that I'll be 'offline'. Here are 3 ways to send your Man pages to something other than your computer terminal.

What if you have a command that could be either a user command or a library
call but you want to see both of them? You're lazy (like me) and don't want to
type: man 1 sleep, man 3 sleep but want to see one after the other? By typing
man -a <command> the Man utility will display the command in succession. Once the first one is complete it will go to the next man page.

One last tip before we head off to Info, the one I love showing off to my
minions from time to time...this one needs no explanation so I'll leave it to
your imagination:

More often than not you need to check the format of config files - man 5 is the key usually for example I always forget the format of crontab files - "man 5 crontab" then reminds me of the relative formatting

Usually (and of course there are exceptions that actually confirm the rule !) man pages SUCK ! and they do not have the simplest of examples that would be worth the 1000 words written in the academic jargon that reminds you mostly UNIX was born in the CS departments of the universities. That's where the power of the community and the internet come in handy to "translate" these for the rest of us.

man -k on a console is my favorite help command. You don't need apropos. If I feel the need, I use Konqueror's support for man and info pages. There is some great doc in man 7, for example glob, regex, signal, oh and heir :-) Although it would have been nice if you could search man by fhs.

I would add to your less commands:
- g and G for top and bottom of man page
- you have /search forward. ?searches backward and then
like / you use n (or N to reverse direction) to find next.
Of course these are documented in man less :-)

System installed man pages are easy to access, fast, uncomplicated with adornments, and provide concise information to get the job done quickly.

I'm going to work again as system administrator after a few years in which I've made something different, so I need to refresh my memory! This article helped me as well as gave me the possibility to learn something new! Thanks again.

Once I read Unix power tools regarding 'man' usage, but your article brings the point in no time. It's quick and informative. Your dialog between info and man is gentle, thanks for not going to much political talk. And special thanks for "ps2pdf", It will be of great use to me.

Note - this is strictly the reference document. They don't have to include examples (most don't), or why to use. These are the HOW to use.

Info - provided by the FSF, and include user guides, why to use, when to use. These guides provide much more background information on the topic. It was expected that the developer provide the man pages.

But not everything is in the info pages, as these are used to cover some more esoteric operation. It also depends on the author (who is more likely not the developer) to choose the subject.

> Why two of them you ask? I have no clue, you would have to ask the FSF about that. It can be really confusing when you 'man sed' and read the short information stored in sed's Man page, then 'info sed' and find a lot more information stored in the Info pages.

The reason for that is that documentation for certain utilities like tar are published under GNU FDL, which makes it impossible to put into the man pages. See the tar man page under BUGS for example.

Trending Topics

Webinar: 8 Signs You’re Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th

Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.