MANPATH(5) /etc/man_db.conf MANPATH(5)

名称

manpath - 格式化 /etc/man_db.conf 文件

描述

manpath 配置文件是手册页工具程序用来在运行时访问用户的 manpath 的。它指示了哪些手册页层次结构(manpath)应视为系统层次结构,并向它们分配用于保存 cat 文件的目录。

如果已经设置了环境变量 $MANPATH,/etc/man_db.conf 中包含的信息不会覆盖它。

搜索路径

默认情况下,man-db 检查用户的 $PATH。对每个找到的 path_element,它会将 manpath_element 添加至搜索路径。

如果对于一个给定的 path_element 在配置文件中不存在对应的 MANPATH_MAP 行,则它将添加 path_element/../manpath_element/manpath_element/../share/manpath_element/share/man 这些路径中所有存在的目录至搜索路径中。

在此之后,它将添加配置文件中所有的 MANDATORY_MANPATH 条目至搜索路径中。

Finally, if the --systems option is used or the $SYSTEM environment variable is set, then that should consist of a sequence of operating system names separated by commas or colons. This acts as a template, expanding the search path once more to allow access to other operating systems' manual pages: for each system name, man-db looks for that name as a subdirectory of each entry in the search path, and adds it to the final search path if it exists. A system name of man inserts the normal search path without subdirectories. For example, if the search path would otherwise have been /usr/share/man:/usr/local/man, and $SYSTEM is set to newOS:man, then the final search path will be /usr/share/man/newOS:/usr/share/man:/usr/local/man/newOS:/usr/local/man.

$MANPATH 环境变量会覆盖 man-db 的默认手册页搜索路径。大部分用户不应该需要对此进行设置。其语法类似 $PATH 环境变量:它包含一个目录名称的序列,并使用冒号进行分隔。它会覆盖上文所述的默认搜索路径。

如果 $MANPATH 使用冒号开头,则默认搜索路径将添加到其开头位置。如果 $MANPATH 使用冒号结尾,则默认搜索路径将添加到其结束位置。如果变量的值包含双冒号(::),则默认搜索路径将插入到两个冒号之间。

格式

当前支持以下字段类型:

# 注释
空行或以 # 开头的行将视为注释并忽略。
这种形式的行指定每个自动生成的 $MANPATH 应包含的 manpath。它通常包含 /usr/man
这种形式的行将设置 $PATH 到 $MANPATH 的映射。对于在用户 $PATH 中找到的每个 path_element,会将 manpath_element 添加到 $MANPATH
这种形式的行指示哪些 manpath 视为系统 manpath,还可指定它们的 cat 文件保存在哪里。如果 man 是一个 setuid 程序,此字段类型将尤为重要,因为(当在系统配置文件 /etc/man_db.conf 而不是每个用户配置文件 .manpath 中时)它指示哪些手册页层次结构作为 setuid 用户访问,哪些作为调用用户访问。

系统手册页层次结构通常保存在 /usr 下,如 /usr/man, /usr/local/man/usr/X11R6/man

如果来自某个特定 manpath_element 的 cat 页面不保存,或保存在传统位置,可以忽略 catpath_element

传统的 cat 保存位置无法处理只读方式挂臷的手册页层次结构,因此(考虑到这种情况),可以指定任何有效的目录层次结构来存储 cat。要观察 Linux FSSTND,可以在实际目录的位置使用关键词“FSSTND”。

不幸的是,需要指定 所有 系统 man 目录树的路径,包括替代的操作系统路径,如 /usr/man/sun 和任何的 NLS 区域语言 路径,如 /usr/man/de_DE.88591

由于是按写的顺序逐行解析的,因此必须先列出作为另一层次结构的次级结构的 manpath,否则会出现不正确的匹配。例如,/usr/man/de_DE.88591 应出现在 /usr/man 之前。

这种形式的行定义各种配置变量;请查看默认的配置文件了解手册分页工具使用了哪些变量。它们包括指向各种程序的路径(如 greptbl),和这些程序的默认参数集。
这种形式的行定义手册章节的搜索顺序。如果配置文件中没有 SECTION 指令,默认为:
SECTION 1 n l 8 3 0 2 3type 5 4 9 6 7

如果给出了多个 SECTION 指令,它们的章节列表会被合并。

If a particular extension is not in this list (say, 1mh) it will be displayed with the rest of the section it belongs to. The effect of this is that you only need to explicitly list extensions if you want to force a particular order. Sections with extensions should usually be adjacent to their main section (e.g. "1 1mh 8 ...").

SECTIONS 是此指令的替代名称,也允许使用。

如果终端宽度小于 宽度,将不会创建(若缺少)或显示 cat 页面。默认值为 80。
如果终端宽度大于 宽度,将不会创建(若缺少)或显示 cat 页面。默认值为 80。
如果 宽度 是非零的,对指定宽度的终端将总是格式化 cat 页面,不管实际使用的终端宽度是多少。此数值将覆盖 MINCATWIDTHMAXCATWIDTH
此标志阻止 man(1) 自动创建 cat 页面。

除非完全准确的遵守了这些规则,否则手册分页工具会工作不正常。这些规则过于复杂了。

http://gitlab.com/man-db/man-db/-/issues
http://savannah.nongnu.org/bugs/?group=man-db

2025-05-02 2.13.1