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.


  • 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?

You can put the man pages in this directory:


Accessing directly

And then you can access them directly using man:

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


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


$ manpath
manpath: warning: $MANPATH set, ignoring /etc/man_db.conf

$ echo $MANPATH

You can add things to the MANPATH temporarily:


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.

  • 2
    To suppress manpath warnings about MANPATH being set, you can pass the -q option. – Joseph R. Sep 15 '13 at 14:46
  • 2
    Yes, I know that I can tell to man where to look. I'm looking for a generic, portable way for an generic installation (ie: where is man looking on a standard configuration) – Romuald Brunet Sep 17 '13 at 13:02
  • Do an echo $MANPATH and see what that shows. Those are good places to start looking, or use the manpath command as I showed in my answer. – slm Sep 17 '13 at 13:03

Answer with desciption

I am running Cygwin on Windows 7. When I try


I get nothing. Here is my portable way of finding where to put new man pages.

$ { find / -maxdepth 2 -type d -name "*man*" 3>&2 2>&1 1>&3 | \
grep -v 'Permission denied' >&3; } 3>&2 2>&1

(A note on that crazy command is at the bottom of this answer.)

You could simply replace / with ~. Another possibility is under the Another note section below.

On my machine, the find command returned:


To me, that meant there were two possibilities: /share/man and /usr/man.

I chose to use /usr/man, which you wouldn't, but I needed to do some more exploring.

$ ls -l /usr/man
total 0
drwxr-xr-x+ 1 me Users 0 April 31 17:13 man1

So, where I had the new man files in a doc/ sub-directory of my working directory, I used

$ cp -R doc/* /usr/man/man1

Now, I could get to my "manual" by typing

$ man my_new_executable

If you don't see a likely candidate, you can remove this part or change it, e.g. to -maxdepth 3, or 4, or 5, or however deep it takes to find what you need. When I did so with 3, I found two other candidates, /var/cache/man and usr/share/man , but I had already found a working solution, so I didn't mess with them.

Another note

I believe that /share/man/man1 or /var/cache/man would be available to non-root users, as you had requested. Please, correct me if I am wrong.

The promised note at the bottom

Note that I used the -maxdepth 2 option with find, because I figured that the man directory would be within two directories of the file system root, and I did not want to get too many extraneous directories that somehow had the substring man, as did /lib/gnome-comander.

The extra stuff around the find is there to suppress any Permission denied errors in case you don't have access to su or sudo. Here is a great description of what's happening. (Look for the line that starts with "gniourf_gniourf".)


I have installed a few apps that I compiled, with the respective configures set for installing in ${HOME}/usr/local.

I find now that I have directories


with manpages gnuplot.1, gnuplot-ja.1, python3.1, python3.5.1, libpng.3, libpngpf.3, zlib.3, png.5, so I guess (given my prefix) it is a pretty standard location for apps installed locally.

It is then a candidate location for the cases where one has to choose manually the local man directory.

Of course, one can add arbitrary paths (and should do it even in the usual just case mentioned) for man pages with

export MANPATH="$HOME/usr/local/share/man${MANPATH:+:${MANPATH}}"

(see this).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.