Question

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.

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?

Thanks in advance.

Was it helpful?

Solution

[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'

OTHER TIPS

You'll need to use manpath command.

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.

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

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.

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.

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top