初学者的 Linux manpath 命令教程(5 个示例)
在此页
- Linux 手动路径教程
- Q1。 manpath 命令如何工作?
- Q2。如何在输出中使用 catpath 而不是 manpath?
- Q3。如何让manpath打印调试信息?
- Q4。如何使 manpath 访问其他操作系统手动层次结构?
- Q5。如何使 manpath 使用自定义配置文件?
- 结论
当涉及命令行实用程序时,Linux 中的手册页是第一级支持的首选。大多数人都知道,您只需编写 man [command-name] 就会弹出相应的手册页。但是你知道这些手册页的搜索路径吗?
在本教程中,我们将讨论 manpath,一个向您显示此信息的实用程序。但在我们开始解释之前,值得一提的是,这里的所有示例都已经在 Ubuntu 18.04 LTS 机器上进行了测试。
Linux 手动路径教程
Linux 中的 manpath 命令可帮助您确定手册页的搜索路径。以下是它的语法:
manpath [-qgdc?V] [-m system[,...]] [-C file]
以下是工具手册页对其的描述:
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.
以下是一些 Q&A 风格的示例,它们应该可以让您对 manpath 命令的工作原理有一个很好的了解。
Q1。 manpath 命令如何工作?
基本用法非常简单 - 只需执行 manpath sans 任何选项。
manpath
例如,上面的命令在我的系统上产生的输出是这样的:
/usr/local/man:/usr/local/share/man:/usr/share/man
所以你可以看到,manpath 为手册页生成一个冒号分隔的路径列表。
请注意,您可以使用 -g 命令行选项,以防您想要生成一个由 man-db 配置文件中所有名为 global 的路径组成的 manpath。
Q2。如何在输出中使用 catpath 而不是 manpath?
为此,请使用 -c 命令行选项。
manpath -c
以下是工具手册页解释此操作的方式:
Once the manpath is determined, each path element is converted to its relative catpath.
例如,这是在我的系统上产生的输出:
/var/cache/man/oldlocal:/var/cache/man/local:/var/cache/man
Q3.如何让manpath打印调试信息?
为此,请使用 -d 命令行选项。
manpath -d
例如,这是此命令在我的系统上产生的输出:

同意,你可能不会经常使用这个选项,但你至少应该知道它,以防你需要调试工具输出。
Q4.如何使 manpath 访问其他操作系统手动层次结构?
为此,请使用 -m 命令行选项。以下是工具手册页如何解释此选项:
-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.如何使 manpath 使用自定义配置文件?
默认情况下,manpath 从以下文件中获取信息:
/etc/manpath.config
但是,如果需要,您可以强制 manpath 读取任何其他文件。您可以使用 -C 命令行选项执行此操作。
manpath -C NEWFILE-PATH
结论
如果您的 Linux 命令行工作涉及处理手册页,那么 manpath 命令对您来说是一个有用的工具。在本教程中,我们讨论了大多数 manpath 命令行选项。有关该工具的更多信息,请访问其手册页。