How to Convert Man Pages to PS or PDF Format from the Linux Command Line
Man pages in all versions of Linux are stored as specially formatted and compressed text files, so it’s difficult to share them or read them on other devices. These files are stored in such a way that only the man or xman command issued at a command prompt in a Linux environment can read them. These pages store information about nearly every command stored on a system, and essentially constitute a free source of information installed on every Linux installation, but they’re not portable in the least.
If you need to share content from a man page, then you will need to convert the file to another format before sharing it with someone who doesn’t have access to the man Linux command. You will also need to convert it if you need to read a page in another program, on any other device or if you need to print it out. The conversion task can be accomplished quite easily at a standard Linux Bash command prompt. Once you have a PostScript file you can then convert this to the even more portable PDF format.
First we’ll illustrate how to convert a man page to a PostScript file. Should you need a PDF file, then apply Method 2 after using Method 1.
Method 1: Converting a Man Page to a PS File
Select a graphical command prompt from the Root Window Menu. If your prompt does not end with the “$” symbol, then type bash and press enter. Make sure that you are in the Documents folder of your home directory by issuing the command:
cd ~/Documents
The exact location may differ depending on your particular distribution. Then issue the command:
man -t COMMAND > COMMAND.ps
Replace the “COMMAND” string with the name of the command you want to typeset as a PostScript file. For example, if you had wanted to do this with the fdisk command:
man -t fdisk > fdisk.ps
Type dir at the prompt to make sure the file is there.
Method 2: PDF Formatting for Man Pages
It’s also possible to convert a man page to a PDF file. Issue the following command to receive said file:
man -t COMMAND | ps2pdf – COMMAND.pdf
Using our fdisk example before, you could try:
man -t fdisk | ps2pdf – fdisk.pdf
Type dir at the prompt afterward to make sure the file was created fine.