3

Besides man, info can also provide information of a command.

  1. For the commands I have tried, I find that info provides the same information as man. So I wonder if info always look up manpages? What else does it also loop up? I.e. what is its source?
  2. Do the two provide info for the same set of commands?
Tim
  • 101,790

3 Answers3

4

So I wonder if info always look up manpages?

(Assuming that your question is about standalone-info) Your suspicion is indeed correct. If the standalone program info can not find the corresponding info page, it will look up the man page. It can be demonstrated as follows

First, let us create a man page that does not exist either as man or info. Let us make a fictions command mexico that has no man or info.

To confirm: $ man mexico No manual entry for mexico $ info mexico (opens in Info, but displaces Top) No menu item `mexico' in node `(dir)Top'.

Now, create a simple manpage, and make sure it is in the path. $ mkdir -p $HOME/.myman/man0 $ cat > $HOME/.myman/man0/mexico.0 .TH MEXICO 0 "2018" "Mexico Version 0.0" .SH SEE ALSO adisababa(0), timbuktu(0)

And see that it is accessible from man. The invocation of man is man [section] <name>. export MANPATH=$HOME/.myman:$MANPATH export MANSECT=$MANSECT:0 man 0 mexico

Check the same from info. The invocation is info <node> [topic]. This should open up the same page in info. info mexico 0

Unfortunately, info does this only if the info node is not found. If the node is found, but topic is not, info will simply open that info node, and say the topic was not found. The hint that it is using man pages will be on the first line of info. It should say File: *manpages*.

Unfortunately, the info documentation says nothing about this.

What else does it also look up? I.e. what is its source?

As far as I can tell from the source (since it mentions nothing about it in the official docs), it can read man pages, but the sources suggests nothing else (other than plain info).

The info pages are typically installed in a few system directories. These can be located by greping for '/info' in the strings strings `which info` | grep /info Further info directories can be set by updating INFOPATH. The info files are generated from a their texinfo source.

Do the two provide info for the same set of commands?

No, info and man are two separate utilities with different documentation pages. Many developers prefer to provide both info and man pages, but they exist separately, and some developers may decide to provide only one or the other. As I mentioned previously, info can read man pages if corresponding info files are not found (and you can determine when it is reading a man page). (Man pages are an older system, and does not fall back to info pages at all).

  • Very good answer. Note that you can use M-x man if you want to display a man page in info regardless of whether an info entry exists for the topic or not. – Stéphane Chazelas Sep 05 '18 at 08:57
  • Note that it's not uncommon for man and info pages to be generated from the same source. For instance, zsh info and man pages are both generated from the same yodl source. – Stéphane Chazelas Sep 05 '18 at 09:00
1

No, info is a separate utility, with separate pages. However, nothing stops program authors/documentors from providing the same information for both.

HalosGhost
  • 4,790
  • 2
    info displays man pages if no entry is found in the info directory. You can use M-x man within info to get to a specific man page (regardless of whether there's an info entry for the topic or not). See @rahul's answer for details. – Stéphane Chazelas Sep 05 '18 at 08:55
1

In the following notes, it is important to not confuse Texinfo (texinfo), the stand-alone info reader (info) and the info reader embedded in GNU Emacs (M-x info).

There are two primary Info readers: info, a stand-alone program designed just to read Info files (see What is Info?) and the info package in GNU Emacs, a general-purpose editor.

Texinfo manual: chapter Overview, section Adding Output Formats:

From time to time, proposals are made to generate traditional Unix man pages from Texinfo source. However, because man pages have a strict conventional format, creating a good man page requires a completely different source from that needed for the typical Texinfo applications of writing a good user tutorial and/or a good reference manual. This makes generating man pages incompatible with the Texinfo design goal of not having to document the same information in different ways for different output formats. You might as well write the man page directly.

An info manual has a completely different structure than a man page, see What is GNU Info for?.

According to @Kyle Jones, see https://unix.stackexchange.com/a/77533

The original Texinfo processor and Info document browser were both written in Lisp and ran inside Emacs. The standalone Texinfo utilities came several years later.

Info standalone: chapter Stand-alone Info

Emacs Info and stand-alone Info have nearly identical user interfaces, although customization and other details are different (this manual explains the stand-alone Info reader).

Moreover, GNU Emacs may read a man page (man package, installed by default) and the Info system (makeinfo, info, ...) is based on the principle of creating a documentation system¹. Look at the built-in documentation system of GNU Emacs: M-x describe-function, type man and Enter.

man is an interactive autoloaded Lisp function in man.el.

(man MAN-ARGS)

Get a Un#x manual and put it in a buffer. This command is the top-level command in the man package. It runs a Un#x command to retrieve and clean a manpage in the background and places the result in a Man-mode browsing buffer. [...]

For a manpage from a particular section, use either of the following. "cat(1)" is how cross-references appear and is passed to man as "1 cat".

    cat(1)
    1 cat

To see manpages from all sections related to a subject, use an "all pages" option (which might be "-a" if it's not the default), then step through with Man-next-manpage (M-n) etc. Add to Man-switches to make this option permanent. [...]

We can know which source the Info reader will use, using the options -aw. For more information, look at the manual "info-stnd", section "Invoking Info".

prompt% info -aw dmesg
*manpages*
prompt% info -aw printf
/usr/share/info/libc.info.bz2
*manpages*

¹ For more information, read the manual Texinfo.