Search This Blog

Tuesday, July 24, 2018

saving linux man page.

A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system.
The standard location of the man page is /usr/share/man with man sections as subdirectories (e.g: 1 for user commands, 2 for system calls, 3 for library functions etc.)

File of man pages are in gzip compressed file format!
Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times.

We can use zcat to decompress these files!
zcat uncompresses either a list of files on the command line or its standard input and writes the uncompressed data on standard output. zcat will uncompress files that have the correct magic number whether they have a .gz suffix or not.

zcat /usr/share/man/man1/ls.1.gz

man pages are in troff format!
troff features commands to designate fonts, spacing, paragraphs, margins, footnotes and more. Unlike many other text formatters, troff can position characters arbitrarily on a page, even overlapping them, and has a fully programmable input language.

We can convert troff into pdf format by using groff!
Groff (GNU troff) is a typesetting system that reads plain text mixed with formatting commands and produces formatted output. The output may be PostScript or PDF, HTML, or ASCII/UTF8 for display at the terminal.

[Final Command]
zcat /usr/share/man/man1/ls.1.gz | groff -mandoc  > lsmanpage.pdf