Tricks and tips for finding information in man pages

61,062

Solution 1

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.

Solution 2

Type slash / and then type the string to search for. Then press n to get to the next item, and press N to go to a previous one.

Solution 3

man -k search

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

Solution 4

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.

Solution 5

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:
61,062

Related videos on Youtube

Casebash
Author by

Casebash

Bachelor of Science (Adv Maths) with Honors in Computer Science from University of Sydney Programming C/C++/Java/Python/Objective C/C#/Javascript/PHP

Updated on September 17, 2022

Comments

  • Casebash
    Casebash over 1 year

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

    • Anton Tarasenko
      Anton Tarasenko over 6 years
      man --help/man -h and its more complete sibling man man has search and navigation tips.
    • builder-7000
      builder-7000 over 4 years
      To start a man page and search for a pattern: man -P'less +/pattern' bash
  • Steven D
    Steven D over 13 years
    On most systems you can check out man man to see a full description of the various sections.
  • phunehehe
    phunehehe over 13 years
    man -k == apropos, isn't it?
  • polemon
    polemon over 13 years
    apropos is what I use all the time when looking for something that has not man page for itself.
  • Kristof Provost
    Kristof Provost over 13 years
    '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.
  • Sebastian
    Sebastian about 12 years
    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.
  • user1968963
    user1968963 almost 11 years
    You have left out the most important piece of information: how do I use most to view man pages.
  • Sebastian
    Sebastian almost 11 years
    A similar effect can be achieved using the gman package which establishes a manpage webserver at localhost/cgi-bin/man/man2html.
  • Hi-Angel
    Hi-Angel over 9 years
    It would be cool if there was a program to search a pages by a «keywords». I.e. I recently couldn't remember the name of the c function to find a substring (the strstr()), and I had no an internet around me.
  • Sebastian
    Sebastian over 8 years
    Alternatives on AskUbuntu: askubuntu.com/questions/253705/…
  • Sebastian
    Sebastian over 8 years
    ...yelp being a lighter-weight drop-in replacement for konqueror -- although it has the deficiency of not presenting a table of contents or a disambiguation page for names used in multiple sections. You have to differentiate these explicitly by appending .(section) -- e.g. yelp man:open.2. You can also use <kbd>Ctrl-L</kbd> to open the location bar.
  • Kusalananda
    Kusalananda over 7 years
    @Hi-Angel man -k substring or apropos substring would have helped you.
  • vatsug
    vatsug over 7 years
    @ACK_stoverflow - probably not a good idea to recommend the guy to do > ~/.bashrc as it will overwrite what's in there already. Better to append (>>) or add the lime manually in my opinion.
  • ACK_stoverflow
    ACK_stoverflow over 7 years
    @vatsug Wow good call, here is what my comment should have said: Install it and try it out: aptitude install most; export MANPAGER="most"; man man. To make it permanent: echo 'export MANPAGER="most"' >> ~/.bashrc
  • kenichi
    kenichi over 7 years
    Also, this regex would be useful: /-u($|[,\s]) in case option character is framed with comma. But if you want to see all entries of the option character 'u' (like -u] in [--udp|-u] of netstat manual) you'll need something like this: /-u($|[^a-z]) And if vi or vim is used as pager: /-u\($\|[^a-z]\)
  • kenichi
    kenichi over 7 years
    And to list all man pages which relate to 'search' in specific section (number 3, for instance) one could use this: man -k search -s 3 Also mentioned in superuser.com/a/677969/599957
  • Elliptical view
    Elliptical view about 6 years
    man 1 chmod man 2 chmod does the same thing.
  • Angel Todorov
    Angel Todorov over 5 years
    hey, that's a great tip about the navigation
  • Chiramisu
    Chiramisu over 5 years
    THIS is the best answer. Extra points for using kbd symbols. ;)
  • joelostblom
    joelostblom over 4 years
    Scroll up/down by one page can also be done with ctrl+space / f, which might be helpful depending on which fingers your prefer to use for navigation.
  • b0yfriend
    b0yfriend almost 4 years
    apropos search is equivalent to man -k search :)
  • ShpielMeister
    ShpielMeister over 2 years
    the multiple search terms feature is great! i've used more/less for forever and didn't realize it was available.