应用程序中仅为当前用户安装的Man命令

时间:2021-08-24 13:58:38

Manual files in Linux are stored in /usr/share/man. Before, my application could only be installed by a root user and it put the manual files in this directory. Now, I want to enable non-root installation; to achieve this, all my data and configuration files will be installed under ~/<appname>/. However, manual files copied to home will no longer be accessible by man command.

Linux中的手动文件存储在/usr/ share/manu中。以前,我的应用程序只能由根用户安装,并将手动文件放在这个目录中。现在,我想启用非root安装;为此,我的所有数据和配置文件都将安装在~/ /下。但是,手工复制到home的文件将不再被man命令访问。

What are the usual workarounds to this problem?

解决这个问题的常用方法是什么?

I've thought in creating a "man" command in my application that runs man -M /<man_path>/<appname>/ (as this is easier to users than running the command by themselves). Is this a good option?

我在我的应用程序中创建了一个“man”命令,它运行man -M / / /(因为这比用户自己运行命令更容易)。这是一个好的选择吗?

Thanks in advance.

提前谢谢。

3 个解决方案

#1


3  

[spatel@ap4004 appname]$ export MANPATH=/home/spatel/appname/man

[spatel@ap4004 appname]$ manpath
/home/spatel/appname/man/en:/home/spatel/appname/man

Other workaround is command alias

其他解决方法是命令别名

[spatel@ap4004 appname]$ alias man='man -M /home/spatel/appname/man'

[spatel@ap4004 appname]$ alias man
alias man='man -M /home/spatel/appname/man'

#2


0  

You'll need to use manpath command.

您需要使用manpath命令。

#3


0  

man has new behaviour by default (at least on Fedora 14 and on) that it searches in paths corresponding to PATH environment variable, i.e. for PATH=/xyz/bin it searches /xyz/bin/man, /xyz/share/man and other nearby places. Unless MANPATH is set.

man默认有新的行为(至少在Fedora 14和on上),它在路径环境变量对应的路径中搜索,例如,对于路径=/xyz/bin,它搜索/xyz/bin/man, /xyz/share/man和其他附近的地方。除非MANPATH设置。

You need to unset MANPATH at the end of your .bash_profile, some startup scripts in /etc may set it to spite you.

您需要在.bash_profile的末尾取消设置MANPATH, /etc中的一些启动脚本可能会让您感到不安。

If you don't specify an explicit path list with -M or MANPATH, man develops its own path list based on the contents of the configuration file /etc/man.config. The MANPATH statements in the configuration file identify particular directories to include in the search path.

如果不指定带有-M或MANPATH的显式路径列表,则根据配置文件/etc/man.config的内容开发自己的路径列表。配置文件中的MANPATH语句标识在搜索路径中包含的特定目录。

Furthermore, the MANPATH_MAP statements add to the search path depending on your command search path (i.e. your PATH environment variable). For each directory that may be in the command search path, a MANPATH_MAP statement specifies a directory that should be added to the search path for manual page files. man looks at the PATH variable and adds the corresponding directories to the manual page file search path. Thus, with the proper use of MANPATH_MAP, when you issue the command man xyz, you get a manual page for the program that would run if you issued the command xyz.

此外,MANPATH_MAP语句根据命令搜索路径(即路径环境变量)添加到搜索路径。对于可能位于命令搜索路径中的每个目录,MANPATH_MAP语句指定一个目录,该目录应该添加到手动页面文件的搜索路径中。man查看PATH变量,并将相应的目录添加到手动页面文件搜索路径中。因此,适当地使用MANPATH_MAP,当您发出命令man xyz时,您将获得一个程序的手册页,如果您发出命令xyz,程序将运行该手册页。

In addition, for each directory in the command search path (we'll call it a "command directory") for which you do not have a MANPATH_MAP statement, man automatically looks for a manual page directory "nearby" namely as a subdirectory in the command directory itself or in the parent directory of the command directory.

此外,每个目录的命令搜索路径(我们称之为“命令目录”)你没有MANPATH_MAP声明中,男人会自动查找手册页目录“附近”即一个子目录目录本身的命令或命令目录的父目录。

You can disable the automatic "nearby" searches by including a NOAUTOPATH statement in /etc/man.config.

可以通过在/etc/man.config中包含NOAUTOPATH语句来禁用自动“附近”搜索。

#1


3  

[spatel@ap4004 appname]$ export MANPATH=/home/spatel/appname/man

[spatel@ap4004 appname]$ manpath
/home/spatel/appname/man/en:/home/spatel/appname/man

Other workaround is command alias

其他解决方法是命令别名

[spatel@ap4004 appname]$ alias man='man -M /home/spatel/appname/man'

[spatel@ap4004 appname]$ alias man
alias man='man -M /home/spatel/appname/man'

#2


0  

You'll need to use manpath command.

您需要使用manpath命令。

#3


0  

man has new behaviour by default (at least on Fedora 14 and on) that it searches in paths corresponding to PATH environment variable, i.e. for PATH=/xyz/bin it searches /xyz/bin/man, /xyz/share/man and other nearby places. Unless MANPATH is set.

man默认有新的行为(至少在Fedora 14和on上),它在路径环境变量对应的路径中搜索,例如,对于路径=/xyz/bin,它搜索/xyz/bin/man, /xyz/share/man和其他附近的地方。除非MANPATH设置。

You need to unset MANPATH at the end of your .bash_profile, some startup scripts in /etc may set it to spite you.

您需要在.bash_profile的末尾取消设置MANPATH, /etc中的一些启动脚本可能会让您感到不安。

If you don't specify an explicit path list with -M or MANPATH, man develops its own path list based on the contents of the configuration file /etc/man.config. The MANPATH statements in the configuration file identify particular directories to include in the search path.

如果不指定带有-M或MANPATH的显式路径列表,则根据配置文件/etc/man.config的内容开发自己的路径列表。配置文件中的MANPATH语句标识在搜索路径中包含的特定目录。

Furthermore, the MANPATH_MAP statements add to the search path depending on your command search path (i.e. your PATH environment variable). For each directory that may be in the command search path, a MANPATH_MAP statement specifies a directory that should be added to the search path for manual page files. man looks at the PATH variable and adds the corresponding directories to the manual page file search path. Thus, with the proper use of MANPATH_MAP, when you issue the command man xyz, you get a manual page for the program that would run if you issued the command xyz.

此外,MANPATH_MAP语句根据命令搜索路径(即路径环境变量)添加到搜索路径。对于可能位于命令搜索路径中的每个目录,MANPATH_MAP语句指定一个目录,该目录应该添加到手动页面文件的搜索路径中。man查看PATH变量,并将相应的目录添加到手动页面文件搜索路径中。因此,适当地使用MANPATH_MAP,当您发出命令man xyz时,您将获得一个程序的手册页,如果您发出命令xyz,程序将运行该手册页。

In addition, for each directory in the command search path (we'll call it a "command directory") for which you do not have a MANPATH_MAP statement, man automatically looks for a manual page directory "nearby" namely as a subdirectory in the command directory itself or in the parent directory of the command directory.

此外,每个目录的命令搜索路径(我们称之为“命令目录”)你没有MANPATH_MAP声明中,男人会自动查找手册页目录“附近”即一个子目录目录本身的命令或命令目录的父目录。

You can disable the automatic "nearby" searches by including a NOAUTOPATH statement in /etc/man.config.

可以通过在/etc/man.config中包含NOAUTOPATH语句来禁用自动“附近”搜索。