The standard manual page (man page) system is the definitive offline documentation source across Linux and Unix distributions. While reviewing man pages inside the terminal using pager tools like less is convenient for quick syntax checks, reading long architectural manuals—such as iptables, systemd.service, or ffmpeg—on a terminal screen can be fatiguing. Pager output lacks typography, cannot be printed easily, and lacks cross-page search navigation or bookmarking.
Fortunately, the Linux man utility natively supports groff typesetting and PostScript document generation. By combining the man -t command with Ghostscript’s ps2pdf utility, you can convert any terminal man page into an elegant, publication-quality vector PDF document complete with formatted headers, bold syntax tables, and clear proportional fonts.
Understanding the man to PDF Conversion Pipeline
The conversion process relies on two core Unix pipeline operations:
man -t <command>: The-tflag instructs themancommand to format manual pages usingtrofforgroffto generate standard PostScript (PS) output instead of plain ASCII text.ps2pdf: A Ghostscript post-processor script that takes standard PostScript input and rasterises it into a compliant, vector-sharp Adobe PDF document.
By piping the PostScript stream from man directly into ps2pdf using a Unix pipe (|), the conversion occurs entirely in memory without creating temporary intermediate files on your filesystem.
Prerequisites: Installing Ghostscript
While the man command is installed by default on virtually all Linux distributions, the ps2pdf utility is part of the Ghostscript suite. Verify whether Ghostscript is present by running:
which ps2pdf
If the command returns no output, install Ghostscript using your distribution package manager:
On Ubuntu, Debian, and Linux Mint:
sudo apt update && sudo apt install ghostscript -y
On Fedora, RHEL, and CentOS Stream:
sudo dnf install ghostscript -y
On Arch Linux and Manjaro:
sudo pacman -S ghostscript
How to Convert Any Man Page to a PDF
To convert a manual page, execute the command following this standard syntax:
man -t <command_name> | ps2pdf - <output_filename>.pdf
The single hyphen (-) passed to ps2pdf instructs it to read the PostScript data directly from standard input (stdin).
Example: Converting the curl Man Page
To generate a PDF manual for the popular curl utility:
man -t curl | ps2pdf - curl_manual.pdf
The resulting curl_manual.pdf file is saved to your current working directory. You can inspect its page count and metadata using pdfinfo or open it in any graphical PDF viewer such as Evince, Okular, or Adobe Acrobat.
Converting Man Pages from Specific Manual Sections
Linux manual pages are grouped into numbered sections. For example, section 1 covers general user commands, while section 5 covers file formats and configuration conventions (such as /etc/passwd or crontab):
If you want the manual page for a configuration file rather than the user command, specify the section number before the command name:
To convert the manual for the crontab configuration format (Section 5):
man -t 5 crontab | ps2pdf - crontab_format.pdf
To convert the Linux system call for fork (Section 2):
man -t 2 fork | ps2pdf - fork_syscall.pdf
How to Convert Multiple Man Pages in a Batch Script
If you are building an offline documentation library or onboarding reference guide for your development team, you can batch-process multiple core tools using a simple Bash loop:
for cmd in bash tar grep sed awk rsync ssh; do
echo "Generating PDF for $cmd..."
man -t "$cmd" | ps2pdf - "${cmd}_manual.pdf"
done
This loop iterates through the list of utilities, typesets each manual, and produces professional, standalone PDF reference guides ready for offline study or tablet reading.