我的 Man 脚本应该放在哪里才能工作?

Where should my Man script be located for it to work?

我正在尝试创建一个 man 脚本,但没有成功。我应该将 testScript.1 文件放在我的文件中的哪个位置,以便它作为手册页在视觉上工作?

到目前为止,我已经尝试将它存储在我的主目录中的两个新创建的目录中,如下所示:

~/lab2/man1/testScript.1

我也尝试过将 testScript.1 文件压缩到 tar.xz 文件中,然后使用文件管理器手动将其移动到 /usr/share/man/man1,但是许可似乎由于某种原因被拒绝。

此外,当我尝试时:

man testscript

唯一的结果是:"No manual entry for testscript"

它应该放在哪里,当 "permission is denied" 时我如何把它放在那里谢谢

您可以将手册页放在共享位置(为此您需要 root 权限)或将它们存储在任何您想要的位置并告诉 man 使用该文件夹。

来自 man 手册页:

   -M  path
          Specify the list of directories to search for man pages.  Separate the directories with colons.  An empty list is the same as not specifying -M at all.  See SEARCH PATH FOR MANUAL PAGES.

在我的系统上,我只是启动了 man man,给出了(amonst 其他)以下结果:

ENVIRONMENT
   MANPATH
          If $MANPATH is set, its value is used as the path to search for manual pages.
   ...

FILES
   /etc/manpath.config
          man-db configuration file.

   /usr/share/man
          A global manual page hierarchy.

   /usr/share/man/index.(bt|db|dir|pag)
          A traditional global index database cache.

   /var/cache/man/index.(bt|db|dir|pag)

在检查 /etc/manpath.config 时,我看到了这个:

# There are three mappings allowed in this file:
# --------------------------------------------------------
# MANDATORY_MANPATH                     manpath_element
# MANPATH_MAP           path_element    manpath_element
# MANDB_MAP             global_manpath  [relative_catpath]
#---------------------------------------------------------
...

显然在您的脚本位置和查找 man 页面的位置之间有一个 link。

我可以解释它是如何完成的,但由于我希望这在每个系统上都是不同的,所以我建议您启动提到的命令并阅读配置文件,这是不言自明的。