I'm writing a man page for a program that I am packaging. How can I display the manpage file that I created, to check if it's all right? Is there a way to pass my file directly to the man command instead of having it search the installed manpages by name?

I tried doing things like man myprog.1 and man < myprog.1 but in both cases I got an error saying that the man page could not be found.


man has an option to read a local file: -l

-l, --local-file

Activate `local' mode. Format and display local manual files instead of searching through the system's manual collection. Each manual page argument will be interpreted as an nroff source file in the correct format. No cat file is produced.

If '-' is listed as one of the arguments, input will be taken from stdin. When this option is not used, and man fails to find the page required, before displaying the error message, it attempts to act as if this option was supplied, using the name as a filename and looking for an exact match.

So you can preview your work in progress with:

man -l /path/to/manfile.1

| improve this answer | |
  • 2
    That's essentially Linux-specific. You might want to limit your answer accordingly. – Thomas Dickey Sep 29 '16 at 9:28
  • 5
    @ThomasDickey I only use Linux; you are welcome to edit or add an answer... – jasonwryan Sep 29 '16 at 18:27

The 'old school' way, for systems that pre-date the -l option, is

nroff -man filename | more -s
| improve this answer | |

I've used simply

man ./path/to/man.1

You need to include a slash in the path, otherwise it searches the system directories. Works on the Linux and OS X systems I have (the latter doesn't have -l).

$ cd /tmp
$ cp /usr/share/man/man1/ls.1 .
$ man ls.1
No manual entry for ls.1
$ man ./ls.1     # works
| improve this answer | |

On Solaris, the -M switch to man will override the search-path for manpages:-

man -M path/to/man myprog

Your manpage file must reside in an appropriate subdirectory corresponding to the section and mark-up language, eg: path/to/man/man1/myprog.1 for an nroff-manpage in section 1.

| improve this answer | |

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.