Linux Tips: Introduction to install the complete man manual and other viewing postures

Time:2022-11-24

This article introduces how to install the complete man manual, remove the Chinese version of the man manual, and export the man manual in Linux.

Install the full man page

In Debian system and Ubuntu system, you can execute the following command to install the complete man manual.

This installs documentation for system functions, library functions, etc.

sudo apt-get install manpages 
sudo apt-get install manpages-de 
sudo apt-get install manpages-de-dev 
sudo apt-get install manpages-dev
sudo apt-get install manpages-posix manpages-posix-dev

Remove the Chinese version of the man manual

When the Chinese version of the Linux system is installed, check the help information in the man manual, the default is the Chinese version.

If you want to view the English version of the man manual, you can execute the following command to remove the Chinese version of the man book from the system.

sudo apt-get purge manpages-zh
sudo mandb -c

when executedsudo apt-get purge manpages-zhAfter the command, check the man manual again, and you will see the help information in English.

But after exiting the man manual, you will see an error prompting “Unable to parse…”.

For example, the following prompt appears:

man: cannot resolve /usr/share/man/zh_CN/man1/man.1.gz: No such file or directory
man: cannot resolve /usr/share/man/zh_CN/man7/man.7.gz: No such file or directory

That is, it prompts that the man file of the Chinese version cannot be parsed.

The solution to this phenomenon is to executesudo mandb -cOrder.

This command will update the index database of the man manual, so that after removing the man manual files of the Chinese version, they will not be parsed anymore.

Rebuilding the man page database can take some time. Just wait a bit.

Export man manuals into txt, pdf, html formats

Export to txt format

The easiest way to export the help information of the man manual into txt format is to redirect.

E.g,man grep > grep.txtcommand exportgrepThe help information for the command goes togrep.txtdocument.

However, the txt format file exported by this writing method may have some garbled characters.

If you encounter garbled characters, you can use the following command to export the txt format:

man grep | col -b > grep_man.txt

use herecol -bcommand to strip some control characters.

Export to pdf format

You can use the following command to export the help information of the man manual into pdf format:

man -t grep | ps2pdf - grep_man.pdf

view heregrepThe help information of the command can be replaced with other commands of interest.

On Debian system and Ubuntu system, it should be installed by defaultps2pdfOrder.

If you have not installed this command, you can install it yourself.

View the description information of man ps2pdf,ps2pdfThere are other commands that generate new versions of the pdf format.

For example posted belowps2pdf14Order:

ps2pdf14 – Convert PostScript to PDF 1.4 (Acrobat 5-and-later compatible) using ghostscript

If there is a requirement for the pdf version, you can check the description of man ps2pdf and use the latest version of the command.

export to html format

If you want to export the help information of the man manual into html format, you can use the following command to view the help information of the man manual in the browser:

man -Hfirefox grep

Use Firefox (firefox) browser to view heregrepThe help information of the command can be replaced with other commands of interest.

It can also be replaced with other browsers, such as google-chrome and so on.

After opening the man help information in the browser, use the “Save Web Page As” function of the browser to export the html page.

When executing the above command, you may encounter an error similar to the following:

$ man -Hfirefox grep
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

At this point, you can executesudo apt-get install groffcommand to install the groff package.

If the system has already installed the groff command and still reports an error, you can uninstall it first, and then reinstall the latest version of the groff command.