15

I've a largish man page (psql) that I'm trying to digest. I've tried redirecting the output of man to a file, but the output confuses LibreOffice enough that whole pages are missing, even if I arrange that the lines wrap properly (I set my window width to 79 before I issue the man command then have LibreOffice change the font size to 10 pt.)

So: I could use a different word processor, I guess. Or maybe there are better commands to use than man itself. Or maybe there's a way to bypass LibreOffice and send it directly to my printer (a Brother monochrome laser printer).

In the end, I just need something readable and physical so that I can mark it up with highlighters and write on it.

4dummies
  • 482

5 Answers5

19

You can output the manpage in html using command options.

example to view the manpage for nano:

man --html=firefox nano

use:

man --help

for more information.

Note that you must have the groff package installed. Having the groff command alone from the groff-base package is not enough.

Alternatively, you can google "ubuntu manpage packagename" replacing "packagename" with the actual packagename to view the Ubuntu manpages online.

mchid
  • 44,904
  • 8
  • 102
  • 162
18

For a PDF:

man -t psql > psql.ps
ps2pdf psql.ps
flndr
  • 301
5

A package called man2html-base is already available in the repositories and its job is to convert man pages to an HTML page.

First, you need to install it like so:

sudo apt install man2html-base

Then, you need to find the main compressed man page file for the desired package by running a tool like whereis... taking nano as an example it would be done like so:

whereis nano

Look in the output for a .gz archive file that has got man in its path like:

/usr/share/man/man1/nano.1.gz

Or use man -w ( Thank you to @mchid's comment ) to find the file like so:

man -w nano

Finally, once you find that file, you can convert it to HTML like so:

man2html /usr/share/man/man1/nano.1.gz > ~/nano.html

the > ~/nano.html part will redirect the output to a file called nano.html in your home directory.

Notice: You can try auto detecting the man page file and converting it in one step utilizing bash command substitution like so:

man2html "$(man -w nano)" > ~/nano.html
Raffa
  • 34,963
3

To obtain a printed copy of a man page, say for psql, use:

man -t psql | lpr

Or as @4dummies suggests, if your printer supports duplexing:

man -t psql | lpr -o sides=two-sided-long-edge

One could even create a bash function for convenience:

prman() {
  man -t "$1" | lpr -o sides=two-sided-long-edge
}

and then say:

prman psql

Jim L.
  • 206
1

If you happen to have any KDE applications installed, one clever little trick is to make sure you have the kio-extras and kde-cli-tools packages installed and run this command

kioclient5 copy man:psql file://$HOME/psql.html

It's intended to allow you to load man:psql in something like KDE's Konqueror web browser/file manager hybrid but kio_man will work for anything that supports loading from arbitrary KIOSlaves for its Open File functionality.

ssokolow
  • 2,423