Linux manpath Command Tutorial for Beginners (5 Examples)

Man pages in Linux is the go to spot for first-level support when it comes to command line utilities. As most of you would know, you just write 'man [command-name]' and the corresponding man page pops up. But do you know the path where these man pages are searched for?

In this tutorial, we will discuss manpath, a utility that shows you this information. But before we start with the explanation, it's worth mentioning that all examples here have been tested on an Ubuntu 18.04 LTS machine.

Linux manpath tutorial

The manpath command in Linux helps you determine search path for manual pages. Following is its syntax:

manpath [-qgdc?V] [-m system[,...]] [-C file]

And here's how the tool's man page describes it:

       If  $MANPATH is set, manpath will simply display its contents and issue
       a warning.  If not, manpath will determine a suitable manual page hier?
       archy search path and display the results.

       The  colon-delimited  path  is determined using information gained from
       the man-db configuration file - (/etc/manpath.config)  and  the  user's
       environment.

Following are some Q&A-styled examples that should give you a good idea on how the manpath command works.

Q1. How the manpath command works?

Basic usage is pretty straight forward - just execute 'manpath' sans any option.

manpath

For example, here's what the above command produced in output on my system:

/usr/local/man:/usr/local/share/man:/usr/share/man

So you can see, manpath produces a colon separated list of paths for manual pages.

Note that you can use the -g command line option in case you want to produce a manpath consisting of all paths named as 'global' within the man-db configuration file.

Q2. How to have catpath in output instead of manpath?

For this, use the -c command line option.

manpath -c

Here's how the tool's man page explains this operation:

Once the manpath is determined, each path element is converted to its relative catpath.

For example, here's the output produced on my system:

/var/cache/man/oldlocal:/var/cache/man/local:/var/cache/man

Q3. How to make manpath print debugging information?

For this, use the -d command line option.

manpath -d

For example, here's the output this command produced on my system:

How to make manpath print debugging information

Agreed, you may not use this option very frequently, but you should at least be aware of it in case you need to debug the tool's output.

Q4. How to make manpath access other OS' manual hierarchies?

For this, use the -m command line option. Here's how the tool's man page explains this option:

-m system[,...], --systems=system[,...]
             
If  this  system  has access to other operating sys?
              tem's manual hierarchies, this option can be used to
              include  them  in the output of manpath.  To include
              NewOS's manual page hierarchies use  the  option  -m
              NewOS.

              The  system  specified can be a combination of comma
              delimited operating system names.   To  include  the
              native  operating  system's manual page hierarchies,
              the system name man must be included in the argument
              string.  This option will override the $SYSTEM envi?
              ronment variable.

Q5. How to make manpath use a custom config file?

By default, manpath fetches information from the following file:

/etc/manpath.config

However, if you want, you can force manpath to read any other file. This you can do using -C command line option.

manpath -C NEWFILE-PATH

Conclusion

If your Linux command line work involves dealing with man pages, the manpath command is a helpful tool for you. Here, in this tutorial, we have discussed majority of manpath command line options. For more info on the tool, head to its man page.

Share this page:

0 Comment(s)