Beginner’s Guide: Exploring the Linux manpath Command with 5 Practical Examples

Man pages in Linux are the go-to resource for first-level support when it comes to command-line utilities. As many of you may know, you can simply type man [command-name] to access a command’s manual page. But have you ever wondered where these man pages are searched for in the system?

In this tutorial, we’ll explore manpath, a utility that reveals this information. Before we delve into the explanation, it’s important to note that all the examples provided here have been verified on an Ubuntu 24.04 LTS machine.

Linux manpath Tutorial

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

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

Here is 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 hierarchy 
  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.

Here are some Q&A-style examples to help you understand how the manpath command works:

Q1. How does the manpath command work?

Using the command is straightforward—just run manpath without any options.

manpath

For instance, here’s the output it generated on my system:

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

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

Note that you can use the -g option if you want to include all paths labeled as ‘global’ within the man-db configuration file.

Q2. How can you output catpaths instead of manpaths?

To achieve this, use the -c command-line option.

manpath -c

Here’s how the tool’s man page explains this feature:

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

For example, on my system, the output produced was:

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

Q3. How do you make manpath print debugging information?

You can use the -d command-line option for this purpose.

manpath -d

Here’s the output this command produced on my system:

How to make manpath print debugging information

While this option isn’t used frequently, it’s useful to know it exists for debugging the tool’s output.

Q4. How can you make manpath access manual hierarchies of other operating systems?

For accessing other OS’s manual hierarchies, use the -m command-line option. Here’s what the tool’s man page states:

  -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 can you make manpath use a custom config file?

By default, manpath retrieves information from the following file:

/etc/manpath.config

If you prefer, you can force manpath to read from a different file using the -C command-line option.

manpath -C NEWFILE-PATH

Conclusion

If your work with the Linux command line involves interacting with man pages, the manpath command is a valuable tool. We have covered the majority of its command-line options in this tutorial. For more detailed information, please refer to its man page.

FAQ

What is the primary function of the manpath command?

The manpath command is used to determine the search path for manual pages on Unix-like operating systems.

Can I customize the search path for man pages?

Yes, you can customize it by using the -C option to specify a different configuration file.

Is the manpath tool specific to certain Linux distributions?

No, the manpath tool is not specific to any one distribution; it is available in various Unix-like operating systems, including many Linux distributions.

Can manpath be used to troubleshoot issues with man pages?

Yes, using the -d option, you can print debugging information which can help troubleshoot issues related to man page paths.