Man – Where to Install Manual Pages in User Directory

man

I'm trying to create a Makefile for a small Perl utility I wrote, And I'm struggling to find out a way to find where to install my man page when make is run as a non-root user.

I'm currently parsing the output of manpath to find out the first path in the $HOME directory… and it almost work fine.

Paths I've found are ~/man and ~/share/man

The only problem is that if those directories don't exist in the first place, manpath doesn't output any of them.

Questions

  • Is there a portable way to find out where I should install the man pages in the user's $HOME directory?
  • If not, which one of them should be preferred?

Best Answer

You can put the man pages in this directory:

$HOME/.local/share/man

Accessing directly

And then you can access them directly using man:

man $HOME/.local/share/man/manX/manpage.1.gz

$MANPATH

You can check what the $MANPATH is with the command manpath, or echo out the environment variable $MANPATH.

Examples

$ manpath
manpath: warning: $MANPATH set, ignoring /etc/man_db.conf
/home/saml/apps/perl5/perlbrew/perls/perl-5.14.0/man:/home/saml/.rvm/rubies/ruby-1.9.2-p180/share/man:/home/saml/.rvm/man:/usr/local/share/man:/usr/share/man:/usr/brlcad/share/man:/usr/man:/usr/brlcad/share/man:/usr/brlcad/share/man

$ echo $MANPATH
/home/saml/apps/perl5/perlbrew/perls/perl-5.14.0/man:/home/saml/.rvm/rubies/ruby-1.9.2-p180/share/man:/home/saml/.rvm/man:/usr/local/share/man:/usr/share/man:/usr/brlcad/share/man:/usr/man:/usr/brlcad/share/man:/usr/brlcad/share/man

You can add things to the MANPATH temporarily:

MANPATH=$HOME/.local/share/man:$MANPATH

If you want to make this permanent then add a file in your /etc/profile.d/ directory called myman.bash with the above MANPATH= line in it. This will get picked up system wide for everyone. If you want it to be just for you, then add it to your $HOME/.bash_profile or $HOME/.bashrc.