Need to convert Unix man pages to PDF or print them? This comprehensive guide shows you exactly how to export, print, and save man pages on Linux, macOS, and BSD systems using the man -t command and ps2pdf.
Whether you need a quick reference PDF, want to print documentation for offline study, or need to share man pages with your team, you'll find the complete workflow here.
This guide also includes troubleshooting for common errors and a cheat sheet for quick reference.
Table of Contents
Quick Summary
Use man -t command | ps2pdf - command.pdf to convert any man page to PDF instantly. Replace command with actual command's name.
Example:
man -t man | ps2pdf - man.pdf
Understanding Man Page Export: How man -t Works
When you run man ls, the system retrieves the source file (written in roff format), processes it through groff (the GNU text formatter), and displays it via a pager like less.
Using the -t flag tells man to output PostScript instead—a format designed for printing that can be easily converted to PDF or sent directly to printers. This is the foundation for all export workflows.
What happens behind the scenes:
manlocates the appropriate manual page file (e.g.,/usr/share/man/man1/ls.1.gz)groffformats the roff source into PostScript- The PostScript is either displayed, saved, or piped to another tool
Why PostScript? It's a device-independent page description language that printers understand natively, and it converts cleanly to PDF.
What's New in 2026
Linux Updates:
- Many modern Linux distributions now ship with
groff1.23+ with improved Unicode support. - Systemd-based systems provide systemd and journald documentation through standard man pages.
xdg-openover SSH is unreliable on Wayland-based systems.
macOS Changes:
- macOS Sonoma (14.0+) removed the
pstopdfutility - useps2pdffrom Ghostscript instead. - Preview.app now has no PostScript support in Sequoia (15.0+).
- Ghostscript is now required on macOS for PostScript-to-PDF conversion workflows.
New Tools:
mandocis the default man-page formatter on OpenBSD, FreeBSD, and modern macOS.- Newer
colimplementations produce cleaner plain-text output than older versions. - Modern terminals do not render PostScript. PostScript output must be viewed through a document viewer or converted to PDF.
Prerequisites
Tools Required (What You Need)
Throughout this guide, we will be using the following tools:
- man - Manual page viewer (standard on all Unix systems)
- groff - GNU troff text formatter
- ps2pdf - PostScript to PDF converter (part of Ghostscript)
- lp / lpr - CUPS printing commands
- mandoc - BSD manual page formatter
- col - Filter reverse line feeds from input
Already installed on most systems:
man- Manual page viewer (standard on all Unix/Linux)grofformandoc- Manual page formatting systems (groff on Linux, mandoc on BSD/macOS)col- Text filter for cleaning up formatted output (part ofutil-linuxon Linux)
For PDF conversion (requires installation):
ps2pdf- PostScript to PDF converter- Part of Ghostscript package
- Not included by default on macOS
For printing:
- CUPS (Common Unix Printing System) with configured printer
lporlprcommand
Installing Ghostscript (for ps2pdf)
To install Ghostscript in Linux, use the following commands.
Linux:
# Alpine Linux apk add ghostscript # Arch Linux / EndeavourOS / Manjaro sudo pacman -S ghostscript # Debian / Ubuntu / Linux Mint / Pop!_OS sudo apt update && sudo apt install ghostscript # RHEL / Fedora / CentOS / AlmaLinux / Rocky Linux sudo dnf install ghostscript # OpenSUSE sudo zypper install ghostscript
BSD:
# FreeBSD
sudo pkg install ghostscript
# OpenBSD
doas pkg_add ghostscript
# NetBSD
pkgin install ghostscript
macOS:
# Using Homebrew (install from https://brew.sh if needed) brew install ghostscript # Or using MacPorts sudo port install ghostscript
Verify Installation
Check if tools are available:
which ps2pdf # Should return: /usr/bin/ps2pdf or similar which man # Should return: /usr/bin/man which groff # Should return: /usr/bin/groff lpstat -p # Lists configured printers
If ps2pdf is missing after installing Ghostscript, try:
# Find where it was installed find /usr -name ps2pdf 2>/dev/null # Or check Ghostscript version gs --version
Exporting a Man Page to PDF (Recommended Workflow)
PDF is the most portable format for sharing and archiving man pages.
Basic PDF export
man -t ls | ps2pdf - ls.pdf
This command converts the ls manual page into a PDF file named ls.pdf.
Breaking this down:
man -t lsgenerates PostScript for thelscommand|pipes the output to the next commandps2pdfconverts PostScript to PDF-tellsps2pdfto read from standard inputls.pdfis the output filename
Export a Man Page to PDF and Open it in One Command
The following commands will convert the given command's manual page into a PDF file and open that PDF immediately in your desktop viewer.
Linux:
man -t ssh | ps2pdf - ssh.pdf && xdg-open ssh.pdf
macOS:
man -t ssh | ps2pdf - ssh.pdf && open ssh.pdf
BSD with mandoc:
mandoc -Tpdf /usr/share/man/man1/ssh.1 > ssh.pdf && xdg-open ssh.pdf
Specify Man Page Sections
Man pages are organized in numbered sections (1 for commands, 5 for file formats, etc.).
To export from a specific section:
man -t 5 passwd | ps2pdf - passwd.5.pdf
This exports the passwd file format documentation (section 5) rather than the passwd command (section 1).
Man page section numbers:
- 1: User commands (ls, grep, etc.)
- 2: System calls (fork, open, etc.)
- 3: Library functions (printf, malloc, etc.)
- 4: Special files (devices in /dev)
- 5: File formats (passwd, fstab, etc.)
- 6: Games
- 7: Miscellaneous (regex, ascii, etc.)
- 8: System administration commands (mount, iptables, etc.)
Batch Export Multiple Manual Pages
You can export multiple man pages in one go like below:
for cmd in ls grep sed awk; do
man -t "$cmd" | ps2pdf - "${cmd}.pdf"
doneUse quotes around variables to handle edge cases safely.
This loop:
- Converts the manual pages for ls, grep, sed, and awk
- Saves each one as a separate PDF
- Produces the files namely ls.pdf, grep.pdf, sed.pdf and awk.pdf.
It runs the same workflow four times, once per command.
Printing Man Pages
Print directly without Saving Files
man -t du | lp
This sends PostScript directly to your default printer. No intermediate files are created.
If you want to preview before printing, run:
man -t du | ps2pdf - du.pdf
Print to a Specific Printer
Check available printers first:
lpstat -p
Then specify the printer:
man -t date | lp -d HP_LaserJet_Pro
Replace HP_LaserJet_Pro with your actual printer name from lpstat.
Print only Specific Man Pages
For lengthy man pages like bash:
man -t bash | lp -P 1-5,10
This prints pages 1-5 and page 10. Note these are physical page numbers, not man page section numbers.
If you want to preview page numbers first, do:
man -t bash | ps2pdf - bash.pdf
Then inspect page ranges before printing.
Print in Landscape Orientation
Useful for pages with wide tables or long command lines:
man -t ip | lp -o landscape
You can also open and inspect the layout before printing using command:
man -t ip | ps2pdf - ip.pdf
Adjust Margins and Scaling
man -t df | lp -o scaling=110 -o page-left=36
Options depend on your printer driver. Common options include:
scaling=<percent>- Increase or decrease size (default 100)page-left=<points>- Left margin in points (72 points = 1 inch)page-top=<points>- Top margin in points
Please note that scaling can cause clipping.
- Enlarged content may run off the page
- Long lines may wrap unexpectedly
Always test with a preview first.
To inspect margins and scale before printing, run:
man -t df | ps2pdf - df.pdf
Working with PostScript Files
Sometimes you need the intermediate PostScript file for review or conversion with other tools.
Save a Man Page as PostScript
man -t sort > sort.ps
View PostScript files
Linux/BSD:
evince sort.ps # or okular sort.ps # or xdg-open sort.ps
macOS:
open sort.ps # Opens in Preview
Convert Existing PostScript to PDF
If you already have a .ps file:
ps2pdf sort.ps sort.pdf
This command saves the sort manual page as a PostScript file named sort.ps.
Exporting Man Pages as Plain Text
For searching, version control, or email, plain text is often better than formatted output.
Clean Text Export
man sort | col -bx > sort.txt
This command saves the sort manual page as clean plain text in a file called sort.txt.
The col -bx command removes:
- Backspace characters used for bold/underline
- Control characters
- Overstrike formatting
This creates clean, searchable text suitable for grep command, editors, or email.
Plain Text with Basic Formatting Preserved
man sort | col -b > sort.txt
Omitting the -x flag preserves some basic formatting while still removing control characters.
BSD-Specific: Using mandoc
Modern BSD systems (OpenBSD, FreeBSD) use mandoc instead of groff. It can generate PDF directly without PostScript as an intermediate format.
Direct PDF Generation
mandoc -Tpdf /usr/share/man/man1/ls.1 > ls.pdf
It converts the ls manual page directly into a PDF file, without using man, groff, or Ghostscript. This is common on BSD systems and macOS.
Find the Man Page Source File
man -w ls
This prints the path to the man page file, which you can then pass to mandoc.
Sample Output:
/usr/share/man/man1/ls.1.gz
Complete Workflow
mandoc -Tpdf "$(man -w ls)" > ls.pdf
It finds the real source file for the ls manual page and converts it directly to PDF.
Troubleshooting Common Problems
Error: "ps2pdf: command not found"
Cause: Ghostscript is not installed.
Solution - Install Ghostscript:
# Debian/Ubuntu sudo apt install ghostscript # RHEL/Fedora/CentOS sudo dnf install ghostscript # Arch Linux sudo pacman -S ghostscript # macOS (requires Homebrew) brew install ghostscript # FreeBSD sudo pkg install ghostscript9-base # OpenBSD doas pkg_add ghostscript
After installation, verify: which ps2pdf should return a path like /usr/bin/ps2pdf.
Error: "Can't open display" when using xdg-open
Cause: Attempting to open a GUI application over SSH without X11 forwarding.
Solutions:
Option 1 - Use X11 forwarding:
ssh -X user@host man -t ls | ps2pdf - ls.pdf && xdg-open ls.pdf
Option 2 - Copy to local system:
# On remote system man -t ls | ps2pdf - ls.pdf # On local system scp user@host:ls.pdf .
Option 3 - Just create the PDF (skip opening):
man -t ls | ps2pdf - ls.pdf # Copy manually or view later
Garbled Output or Empty PDF
Common causes and fixes:
1. Missing groff:
# Verify groff is installed which groff # Install if missing sudo apt install groff # Debian/Ubuntu sudo dnf install groff # RHEL/Fedora
2. Man page doesn't exist:
# Check if the man page exists man -w commandname # If it returns nothing, the man page isn't installed
3. Corrupted man page:
# Try a different man page to rule out corruption
man -t man | ps2pdf - test.pdf
If this works, the original man page is corrupted
Error: "No manual entry for command"
Cause: The command's documentation isn't installed.
Solutions:
Install documentation package:
# Ubuntu/Debian sudo apt install manpages manpages-dev # For specific software, install its -doc package sudo apt install git-doc python3-doc
Search for the command:
# Find which package provides the man page apt-cache search "man page" | grep commandname
Warning: "some characters couldn't be converted to PostScript"
Cause: The man page contains Unicode characters not supported in PostScript.
Solution:
# Force UTF-8 encoding man -t -Tutf8 command | ps2pdf - output.pdf # Or use col to clean the output first man command | col -bx > clean.txt # Then work with the text file
Printing to Wrong Printer or No Default Set
Check available printers:
lpstat -p
Set default printer:
lpoptions -d printer_name
Always specify printer explicitly:
man -t ls | lp -d correct_printer_name
Check print queue:
lpstat -o # Show pending jobs cancel job_id # Cancel a job if needed
PDF Output Has Tiny or Wrong Fonts
Cause: Font embedding issues with Ghostscript.
Solution - Force font embedding:
man -t ls | ps2pdf -dEmbedAllFonts=true - ls.pdf
Or adjust PDF settings:
man -t ls | ps2pdf -dPDFSETTINGS=/printer - ls.pdf
Options for -dPDFSETTINGS:
/screen- Low resolution (72 dpi), smallest files/ebook- Medium resolution (150 dpi)/printer- High resolution (300 dpi) - Recommended/prepress- Highest quality (300+ dpi), large files
Man Page Missing Sections or Truncated
Cause: Insufficient processing or complex formatting.
Solution 1 - Use plain text export:
man command | col -bx > command.txt
After exporting, verify all content is there.
Solution 2 - Increase groff memory:
groff -Tps -man /usr/share/man/man1/command.1 | ps2pdf - output.pdf
Permission Denied When Printing
Cause: User not in printer group or CUPS access restrictions.
Solution:
# Add user to lp group sudo usermod -aG lp $USER # Log out and back in for group changes to take effect # Or check CUPS permissions sudo nano /etc/cups/cupsd.conf # Ensure your user has access
macOS: "Preview can't open PostScript file"
Cause: Recent macOS versions have limited PostScript support.
Solution 1 - Use ps2pdf:
man -t command | ps2pdf - command.pdf && open command.pdf
Solution 2 - Alternative Preview method:
man -t command | open -f -a Preview # If this fails, PostScript support is disabled
Solution 3 - Install Ghostscript:
brew install ghostscript # Then use ps2pdf as shown above
BSD: "mandoc: ERROR: cannot read"
Cause: Incorrect file path or permissions.
Solution:
# Find the correct path man -w command # Use the full path mandoc -Tpdf "$(man -w command)" > output.pdf # Check file permissions ls -l "$(man -w command)"
Output Doesn't Include Section Number in Filename
Not an error, but common confusion.
To include section numbers in exported filenames:
# Get section number first
SECTION=$(man -w grep | sed 's/.*\.\([0-9]\).*/\1/')
man -t grep | ps2pdf - "grep.${SECTION}.pdf"
# Or just add it manually
man -t 5 crontab | ps2pdf - crontab.5.pdfVerifying Successful Export
Always verify your PDF before sharing:
# Check file size (should be > 0 bytes) ls -lh output.pdf # Check PDF integrity pdfinfo output.pdf # Quick visual check xdg-open output.pdf # Linux open output.pdf # macOS
Expected file sizes:
- Small man pages (like
ls): 20-50 KB - Medium man pages (like
bash): 100-300 KB - Large man pages (like
ffmpeg): 500 KB - 2 MB
If your PDF is less than 5 KB, something went wrong.
Practical Use Cases
You might wonder why would I export a man page to pdf or ps format? Here are some use cases.
Create a Personal Reference Library
mkdir -p ~/manuals/pdf
cd ~/manuals/pdf
# Export frequently-used commands
for cmd in bash ssh git rsync tar grep sed awk find; do
man -t "$cmd" | ps2pdf - "${cmd}.pdf"
donePopular Commands to Export
Here are commonly exported man pages for offline reference:
System Administration:
# Core system commands man -t systemctl | ps2pdf - systemctl.pdf man -t journalctl | ps2pdf - journalctl.pdf man -t crontab | ps2pdf - crontab.pdf man -t sudo | ps2pdf - sudo.pdf # File system and disk management man -t mount | ps2pdf - mount.pdf man -t fdisk | ps2pdf - fdisk.pdf man -t df | ps2pdf - df.pdf man -t lsblk | ps2pdf - lsblk.pdf
Networking:
# Network utilities man -t ip | ps2pdf - ip.pdf man -t netstat | ps2pdf - netstat.pdf man -t ss | ps2pdf - ss.pdf man -t iptables | ps2pdf - iptables.pdf man -t tcpdump | ps2pdf - tcpdump.pdf
Development Tools:
# Git and version control man -t git | ps2pdf - git.pdf man -t git-commit | ps2pdf - git-commit.pdf man -t git-rebase | ps2pdf - git-rebase.pdf # Compilers and build tools man -t gcc | ps2pdf - gcc.pdf man -t make | ps2pdf - make.pdf man -t cmake | ps2pdf - cmake.pdf
Docker and Containers:
man -t docker | ps2pdf - docker.pdf man -t docker-compose | ps2pdf - docker-compose.pdf man -t podman | ps2pdf - podman.pdf
Text Processing:
# Essential text tools man -t grep | ps2pdf - grep.pdf man -t sed | ps2pdf - sed.pdf man -t awk | ps2pdf - awk.pdf man -t find | ps2pdf - find.pdf man -t xargs | ps2pdf - xargs.pdf
Shell Scripting:
# Bash reference man -t bash | ps2pdf - bash.pdf man -t zsh | ps2pdf - zsh.pdf # Configuration files man -t 5 bashrc | ps2pdf - bashrc.pdf man -t 5 crontab | ps2pdf - crontab-format.pdf
Share documentation with a colleague
man -t systemctl | ps2pdf - systemctl-reference.pdf # Email or upload systemctl-reference.pdf
Study Offline or Annotate
Export to PDF, then open in a PDF reader that supports annotations. This is particularly useful for studying complex commands like iptables or ffmpeg.
Quick Printer Test
man -t cal | lp
The cal man page is short—perfect for testing printer configuration.
Limitations and Considerations
1. Output appearance:
Man pages converted this way are functional but not styled. They use basic fonts and simple layouts. For public documentation, consider tools like Pandoc or dedicated documentation systems.
2. Not all formatting survives:
Complex tables, special symbols, or formatting may not convert perfectly. Always verify the output before sharing widely.
3. Resource usage:
Printing consumes paper and ink. Use print preview or PDF export for review before sending jobs to the printer.
4. Alternative tools exist:
For HTML export, consider man2html. For styled PDFs, look at documentation generators like Sphinx or Asciidoctor if you're creating reference materials from scratch.
Advanced Tips
Create a Shell Function for Quick Exports
Add to your ~/.bashrc or ~/.zshrc:
manpdf() {
local name="${*: -1}"
local open_cmd="xdg-open"
command -v open >/dev/null && open_cmd="open"
man -t "$@" | ps2pdf - "${name}.pdf" && "$open_cmd" "${name}.pdf"
}Usage:
manpdf grep
Export with Custom Filename
man -t 5 crontab | ps2pdf - crontab-file-format.pdf
Combine Multiple Manual Pages into one PDF
# Export individually
man -t ls | ps2pdf - /tmp/ls.pdf
man -t cp | ps2pdf - /tmp/cp.pdf
man -t mv | ps2pdf - /tmp/mv.pdf
Combine all PDFs using pdfunite:
pdfunite /tmp/ls.pdf /tmp/cp.pdf /tmp/mv.pdf file-commands.pdf
Or using Ghostscript:
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \
-sOutputFile=file-commands.pdf \
/tmp/ls.pdf /tmp/cp.pdf /tmp/mv.pdf
You can also use pdftk utility:
pdftk /tmp/ls.pdf /tmp/cp.pdf /tmp/mv.pdf cat output file-commands.pdf
For more details, refer this guide:
Frequently Asked Questions (FAQ)
A: Use the command: man -t command_name | ps2pdf - output.pdf. For example, to convert the grep man page: man -t grep | ps2pdf - grep.pdf. This requires ps2pdf from the Ghostscript package.
A: This error means Ghostscript isn't installed. Install it with:
- Debian/Ubuntu: sudo apt install ghostscript
- RHEL/Fedora: sudo dnf install ghostscript
- macOS: brew install ghostscript
- FreeBSD: sudo pkg install ghostscript
A: Use man -t command | lp to print to your default printer, or man -t command | lp -d printer_name to specify a printer. Check available printers with lpstat -p.
A: Yes! Use man -t command | open -f -a Preview to open the man page directly in Preview, then save as PDF. Note that recent macOS versions removed pstopdf, so for direct conversion you'll need ps2pdf from Ghostscript.
A: The -t flag tells man to output PostScript format instead of displaying in a pager. PostScript is a printer language that can be converted to PDF or sent directly to printers. Think of it as the print-ready version of the man page.
A: Use a loop:for cmd in ls grep sed awk; do
man -t "$cmd" | ps2pdf - "${cmd}.pdf"
done
A: The terminal uses ANSI formatting (bold, underline) while PDF uses actual fonts. The content is identical, but the visual presentation differs. This is normal and expected.
A: Man pages are organized in sections (1-8). Use man section_number command. For example, man 5 passwd shows the passwd file format (section 5) rather than the passwd command (section 1). Export with man -t 5 passwd | ps2pdf - passwd5.pdf.
A: Yes! Here's a function to add to your .bashrc:manpdf() {
man -t "$@" | ps2pdf - "${1}.pdf" && xdg-open "${1}.pdf"
}
Then use: manpdf grep
A: These produce different PDF versions:
- ps2pdf - Default (currently PDF 1.4)
- ps2pdf12 - PDF 1.2 (Acrobat 3+ compatible)
- ps2pdf13 - PDF 1.3 (Acrobat 4+ compatible)
- ps2pdf14 - PDF 1.4 (Acrobat 5+ compatible)
For maximum compatibility, use ps2pdf13. For modern systems, the default ps2pdf is fine.
A: Use: man command | groff -mandoc -Thtml > command.html. However, PDF is generally more reliable and portable for man pages.
A: Yes! BSD systems with mandoc can generate PDF directly: mandoc -Tpdf /usr/share/man/man1/ls.1 > ls.pdf. Find the man page path with man -w ls.
A: You're trying to open a GUI application over SSH without X11 forwarding. Either use ssh -X for X11 forwarding, or copy the PDF to your local machine: scp user@host:file.pdf .
A: Use the -P option with lp: man -t bash | lp -P 1-5 prints only pages 1-5. Note these are physical page numbers, not section numbers.
A: Use apropos keyword to search man page names and descriptions. For example, apropos compress finds all compression-related commands.
A: While possible, it's complicated and rarely produces good results. Man pages are designed for terminal and print display. For documentation in other formats, look for official project documentation rather than converting man pages.
Key Takeaways
- Prerequisites: Most systems have
manandgroff; PDF conversion requiresps2pdf(Ghostscript) - PDF Export:
man -t command | ps2pdf - output.pdfconverts man pages to portable PDFs - Direct Printing:
man -t command | lpsends man pages straight to your printer - Plain Text:
man command | col -bx > output.txtcreates clean, searchable text files - macOS Special:
man -t command | open -f -a Previewopens in Preview without extra tools - BSD Alternative: Systems with
mandoccan usemandoc -Tpdf $(man -w command) > output.pdf
Cheat Sheet
Convert man page to PDF (Linux/macOS):
man -t ls | ps2pdf - ls.pdf
Print man page directly:
man -t command | lp
Export to plain text:
man command | col -bx > command.txt
macOS: Open in Preview:
man -t ssh | open -f -a Preview
For more details, refer the manual page of the respective command:
man man- Learn more about the man systemman groff- GNU roff text formatter documentationman mandoc- BSD manual page formatter (BSD systems)man lp- Send jobs to CUPS printersman ps2pdf- PostScript to PDF converter options
Alternative Approaches
Here's a few alternative approaches for man -t:
- Pandoc - Universal document converter (can convert Markdown to man pages)
- ronn / ronn-ng - Generate man pages from Markdown
- help2man - Generate simple man pages from program help output
- man2html - Convert man pages to HTML (less reliable than PDF)
Summary
Exporting and printing manual pages is straightforward once you understand the PostScript workflow. The core command "man -t" generates printer-friendly output that you can save, convert, or print directly.
For most users, the PDF workflow (man -t command | ps2pdf - output.pdf) provides the best balance of portability and quality. For quick prints, piping directly to lp eliminates intermediate files. For text processing, col -bx creates clean, searchable output.
These techniques use standard Unix tools that have been stable for decades. They work across distributions and Unix variants with minimal dependencies. Master these basics, and you'll have reliable documentation access regardless of your environment.
Resources
- Linux man-pages project - Source for Linux man pages
- CUPS Printing Guide - Printer options reference
- Ghostscript Documentation - ps2pdf details
- groff Manual - Text formatting system
Related Read:
- Learn To Use Man Pages Efficiently In Linux
- Efficiently Search Linux Manual Pages
- Good Alternatives To Man Pages Every Linux User Needs To Know
- View A Specific Section In Man Pages In Linux
- Find Longest Man Page In Linux
- Easily Recall Forgotten Linux Commands
- Create And Maintain Your Own Man Pages
- Install Man Pages In Alpine Linux
- Install Missing Man Pages Of Commands On Ubuntu
- Pinfo – A CLI Program To Read Info And Man Pages In Color
- Find Command Help In Linux (Man, Info, Apropos, Whatis, –help)
- Browse And Read Entire Arch Wiki As Linux Man Pages
- Display Linux Commands Cheatsheets With Tealdeer Tool
- Display Linux Commands Cheatsheets Using Eg
- Navi: An Interactive Commandline Cheatsheet Tool
- Search, Study And Practice Linux Commands On The Fly Using Tldr++
