Getting Help from Linux - Part 1 Man Pages

man woman

No manual entry for woman

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
  1. User Commands
  2. System Calls
  3. Library Calls
  4. Special Files
  5. File Formats
  6. Games
  7. Miscellaneous
  8. System Administration
  9. 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
Environment
- Environmental variables that affect the program, function, file, etc
Bugs
- Known bugs
See Also
- This is very useful section. This will reference related Man pages.
Author (or History)
- Who wrote it, and/or who contributed to it.

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.

*Navigation - Usually uses Less
Up/Down- Up & Down Keys.
Page Up & Down - PgUp/PgDn Keys
Search - '/foo'
Search Next - '/' or N key
Summary of Commands (help) - h key
Quit - q key
Down 1 Screen - Spacebar or D key
Up 1 Screen - B key
Down 1 line - Enter

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:

man -k sleep

apmsleep (1)         - go into suspend or standby mode and wake-up later
clock_nanosleep (2)  - high-resolution sleep with specifiable clock
nanosleep(2)         - high-resolution sleep 
rtcwake (8)          - enter a system sleep state until specified wakeup time 
sleep (1)            - delay for a specified amount of time 
sleep (3)            - Sleep for the specified number of seconds 
usleep (3)           - suspend execution for microsecond intervals 

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.

# Send sleep manpage to default printer
man sleep | col -b | lpr
# Send sleep manpage to ps2pdf utility (must have installed) and save as sleep.pdf
man -t sleep | ps2pdf - sleep.pdf
# dump the sleep Man page to a text file
man sleep | col -b > sleep.txt

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:


man hier

Part II of 'Getting help from linux' will cover Info. Stay Tuned!

______________________

www.jaysonbroughton.com

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

easy of use

Sprinklers's picture

Very useful to me as i have restricted internet access, command line and the info is there! Great help :)

Thanks for this

ariethavans's picture

Thanks for this information.It is a great post.

man 5 option

Andrew Rimmer's picture

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

man -k

Jesse Pollard's picture

Actually, man -k does something different.

makewhatis - scans the man pages and creates a searchable index of the synopsis. This will unpack the (frequently) compressed man pages to get the synopsis. This takes quite a while to do.

man -k searches the index for the keyword, and provides a list of files to the pager (less/more) to process.

This is different than searching the files, which would take FAR longer.

This is also why you don't always find the man page you are looking for after updates when asking for the page works - the index needs to be rebuilt.

Thanks

Viktor's picture

So many years in Linux, didn't have a clue how to use the man pages. thanks a ton.

info: is understood by KDE konqueror

cjcox's picture

For Linux fans, you can use KDE to easily browse info pages. It was really designed as a hyperlink doc system, though for emacs apparently...

Bring up konqueror, type info: as the url. Enjoy.

If you prefer text based, I always liked pinfo because it uses the lynx browser style shortcuts I believe by default.

So I'm not an emacs person.. shoot me!

You can do the same using

cjcox's picture

You can do the same using man: as well... if that's interesting.

Usually (and of course there

cowardly Larry's picture

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

Anonymous's picture

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.

the next past ??

Anonymous's picture

where is next part ??

It's coming

Jayson Broughton's picture

I didn't expect to split this up until the very end. Working on the 2nd part now. You should see it here shortly :-)

I found this useful. I have

Isaac's picture

I found this useful.
I have always wanted to be able to search man pages, and now I see I can!

Thanks

Mik's picture

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.

Well written.

SR RAJESH KUMAR's picture

Dear Jayson,

Good Day,

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.

with cheers,
rajesh!

info was probably not needed

Mayuresh's picture

I don't know why info was born. Its creators must have had their reasons.

For a long time man user, there is definitely some inertia to learn new navigation commands.

You know how I deal with info? E.g. I realize 'info make' has lot more information than 'man make'. Then I just do the following:

zcat /usr/share/info/make.info* | less

And then browse it like a man page by searching what I want with "/" etc.

I did not find much advantage of navigation in info and never felt motivated enough to learn it.

Weird? May be. Old habits die hard.

Even shorter : zless

Eric Buissonnet's picture

Even shorter :

zless /usr/share/info/make.info*

THIS is AWESOME ! Barney

cowardly Larry's picture

THIS is AWESOME ! Barney Stinson AWESOME ! Thanks for this great tip.

This makes the info files available to the rest of us that don't care to learn yet another paging system.

manpage/info

Jesse Pollard's picture

Traditionally, man pages contained the reference document for commands, libraries, system calls, file formats, special administration procedures, filesystems and devices.

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.

info longer than man pages

alip2890's picture

> 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.

Great Article!

billz's picture

Loved it Jayson! I learn so much from articles like this in Linux Journal. :)
- Bill

How about...

TheFekete's picture

Too bad this one doesn't work:
$> man bearpig

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix