How do I make man pages open in a web browser?

Using the man program

Looking at the manpage of man,

man man

There is the -H option, or its equivalent --html which will generate the HTML for the manual and open them in the browser.

This option will cause groff to produce HTML output, and will display that output in a web browser. The choice of browser is determined by the optional browser argument if one is provided, by the $BROWSER environment variable, or by a compile-time default if that is unset (usually lynx). This option implies -t, and will only work with GNU troff.

So to open any man page in the browser just use:

man -Hfirefox <command>

or

man --html=firefox <command>

Both are the same.

You can use firefox, google-chrome, chromium-browser or any other in place of the firefox word.

Select a default browser permanently

Before calling the man command, use the following command:

export BROWSER=firefox

This way, you can just use man -H or man --html without specifying the browser each time.

man -H ls

You can also add the previous export command to your ~/.bashrc so you won't have to type it each time you open a new terminal and try using man -H

Troubleshoot

If you got an error saying something like this:

man: command exited with status 3: /usr/bin/zsoelim | /usr/lib/man-db/manconv -f UTF-8:ISO-8859-1 -t UTF-8//IGNORE | preconv -e UTF-8 | tbl | groff -mandoc -Thtml

You will need to install the groff package.

sudo apt-get install groff

Using Yelp

If a choice of browser is not relevant, you can use the yelp command which offers navigation through the man pages.

yelp man:<command>
# example: yelp man:ls

Using the Ubuntu Manpage Repository

You can also visit https://manpages.ubuntu.com/ and check almost all man pages there. All versions of the man pages for all the Ubuntu versions are available there. It also features a search functionality.

Of course, the downside of using the website is that you can't access it without being connected to the Internet.


man can actually do a lot of this on its own. You just need to install groff (GNU troff text-formatting system) and then you can use the H flag (cause groff to produce HTML output).

sudo apt install groff
man -Hfirefox bash