Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Does anyone have any tricks and tips for finding information in man pages?

share|improve this question

19 Answers 19

up vote 21 down vote accepted

Pay attention to the section number: Suppose you want help on printf. there are at least two of them: in shell and in C. The bash version of printf is in section 1, the C version is in section 3 or 3C. If you don't know which one you want, type man -a printf, and all manual pages will be displayed.

If what you are looking for is the format of printf with all % codes and it doesn't appear on printf man page, you can jump to related man pages listed under SEE ALSO paragraph. You may find something like formats(5), which suggests you to type man 5 formats.

If you are annoyed that man printf gives you printf(1) and all you want is printf(3), you have to change the order of scanned directories in the MANPATH environment variable and put the ones for C language before the ones for shell commands. This may happen also when Fortran or TCL/Tk man pages are listed before C ones.

If you don't know where to start, type man intro, or man -s <section> intro. This gives you a summary of commands of requested section.

Sections are well defined:

  • 1 is for shell commands,
  • 2 is for system calls,
  • 3 is for programming interfaces (sometimes 3C for C, 3F for Fortran...)
  • 5 is for file formats and other rules such as printf or regex formats.

Last but not least: information delivered in man pages is not redundant, so read carefully from beginning to end for increasing your chances to find what you need.

share|improve this answer
5  
On most systems you can check out man man to see a full description of the various sections. –  Steven D Sep 10 '10 at 15:30

Type slash / and then type the string to search for. Then keep pressing n to get to the next item

share|improve this answer

man -k search

This will give you a list of all man pages which relate to 'search'.

share|improve this answer

The apropos utility is seriously handy for finding the appropriate manpage.

share|improve this answer
1  
man -k == apropos, isn't it? –  phunehehe Sep 10 '10 at 15:49
    
apropos is what I use all the time when looking for something that has not man page for itself. –  polemon Sep 10 '10 at 18:51
    
'man man' says that 'man -k' is equivalent to 'apropos -r'. I think apropos is a little more powerful. I generally use 'man -k' as it's slightly shorter. –  Kristof Provost Sep 11 '10 at 11:25

As @Steven D says, don't forget the info pages.

In addition, don't be intimidated by the info pages. I know plenty of people who don't use the info pages because of the built-in navigation system. My favorite solution is to pipe the info pages through less:

info gpg |less

This way, I can navigate the info pages using my favorite pager. The info pages will now behave the same as man pages.

share|improve this answer

Always check out what's in the SEE ALSO section. Frequently I find other useful commands or functions that way.

share|improve this answer

If you're more comfortable with your editor than you are with the default pager, you can set MANPAGER in your environment. For example, I have this line in my ~/.bashrc:

export MANPAGER="col -b | vim -c 'set ft=man nomod nolist ignorecase' -"

share|improve this answer

Don't ignore the info pages. Many GNU tools have far more extensive info pages than man pages. Often, the SEE ALSO section will say "The full documentation for foo is maintained as a Texinfo manual." This is especially true for anything in the GNU coreutils package.

Also, if you are an emacs user, don't forget you can read info and manual pages without leaving your editor: M-x info and M-x woman.

share|improve this answer

The default pager for reading a man page is less. There is documentation on less here.

In particular:

  • Scroll up/down by one page: b / space
  • Scroll up/down by half a page: u / d
  • Searching forwards/backwards: / / ?, then type a regular expression,
    • then then hit n to go to the next match or
    • shift+ N to go to the previous match.
    • If the page is covered with uninteresting matches, hit space to go to the next page.
  • Add an @ before the regular expression to search from the start.
share|improve this answer

From Kristof answer, if you (i.e.) type man -k chmod you'll get a list of possibilites. Note the number in the parenthesis, it means the section to look for in the manual pages:

On UNIX you can try:

man -s1 chmod it will show the man page for chmod command

man -s2 chmod it will show the man page for the C lib function chmod()

On Linux you should change -s for -S

share|improve this answer

Most of us set the PATH variable. This will show you how to automatically make the man search path match your command search PATH.

Say you append your path to include your personal, work-specific and locally-installed utilities, like export PATH=$PATH:~/bin:/workgroup/bin:/opt/local/bin:. As a side effect, man foo won't show the manpages stored at ~/man , /workgroup/man or /opt/local/man .

To resolve this, I use the manpath command to automatically set the man page search path. For example, my ~/.bashrc has the following. This works for me on a hundred different systems running everything from FreeBSD 4.x, Darwin and CentOS 5:

### PATH & MANPATH
# My personal utilities
export PATH=$PATH:$HOME/bin

### Set the manpath based on the PATH, after man(1) parses man.conf
# - No need to modify man.conf or manually modify MANPATH_MAP
# - Works on Linux, FreeBSD & Darwin, unlike /etc/manpaths.d/
# See "SEARCH PATH FOR MANUAL PAGES" in man(1)
# Just set the man search path. Don't print output to screeen.
manpath >/dev/null

Some systems (Like Apple Leopard) set the MANPATH automatically, but that means that your system will use the MANPATH variable instead of using manpath. As a result, man pages for 'MacPorts' (/opt/local/man) are ignored. I want to control this myself, so I unset MANPATH:

unset MANPATH
manpath >/dev/null
share|improve this answer

Similar to but slightly different from Rob Hoelz's answer,

Add the following in your ~/.vimrc:

let $GROFF_NO_SGR=1
runtime ftplugin/man.vim

Now vimman is an excellent manpage viewer, and :Man from within Vim (or simply hitting K over a keyword) is an excellent manpage browser.

share|improve this answer

I suppose, using most pager is a good idea. This pager is very powerful, but the main feature for me - displaying colored man-pages. This feature improves perception of plain text and eases searching of needed information.

Look at the attached screenshot, text looks very nice, isn't it?

most pager

share|improve this answer
    
You have left out the most important piece of information: how do I use most to view man pages. –  user1968963 May 28 '13 at 18:12

In Linux man, you can do man -K string (note the uppercase K) to do a brute force search of a given term

   -K, --global-apropos
          Search for text in all manual  pages.   This  is  a  brute-force
          search,  and is likely to take some time; if you can, you should
          specify a section to reduce the number of pages that need to  be
          searched.   Search terms may be simple strings (the default), or
          regular expressions if the --regex option is used.

very useful when you don't know where to search.

share|improve this answer

For those longer, more complex man pages I find it much easier to read them away from a computer (odd, I know) and so I have these functions in my .bashrc

# Print man pages 
manp() { man -t "$@" | lpr -pPrinter; }

# Create pdf of man page - requires ghostscript and mimeinfo
manpdf() { man -t "$@" | ps2pdf - /tmp/manpdf_$1.pdf && \
    xdg-open /tmp/manpdf_$1.pdf ;}
share|improve this answer

View man pages in a user-friendly graphical application:

konqueror man:(command)

For the top-level table of contents:

konqueror man:

Features:

  • If you enter a command that has a match in multiple sections, it takes you to a disambiguation page
  • It's a graphical application, so you don't have to remember cryptic key sequences to navigate the page
  • It includes hyperlinks to related pages (including "see also" pages)
  • You can open related pages in separate tabs
share|improve this answer
    
By the way, this also works with info:(command). Some programs provide a lot more information via "info" than via "man", and konqueror provides a much nicer interface for browsing these info pages. Note: Just using info:, also works for getting a top-level table of contents. –  nobar Feb 13 '12 at 2:45
    
A similar effect can be achieved using the gman package which establishes a manpage webserver at localhost/cgi-bin/man/man2html. –  nobar Jun 22 '13 at 17:58

If you're looking for information regarding a bash builtin (such as time, disown, set, or [[), instead of slogging through the detailed bash info page or man bash, you can enter help {builtin-keyword} and get basic syntax information quickly.

share|improve this answer

If you are annoyed that man printf gives you printf(1) and all you want is printf(3), you can tell man you want the printf from section 3 by putting the section before printf, like so: man 3 printf, without having to change the order of scanned directories in the MANPATH environment variable and put the ones for C language before the ones for shell commands.

share|improve this answer

I just use grep. If i were to wonder what the -s option of the read command did, i'd try these commands in order until i got an answer:

info read |grep \\-s

man read |grep \\-s

help read |grep \\-s

In this case only the info command provided a clear answer. This excellent answer gives the details on the different help systems.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.