Some time it is necessary to print a Linux man or info page. To print a ls command man page type the following command:
$ man ls | col -b | lpr -P hp1_floor2
Where,
- col -b : To format man page output, it will not show any special character such as backspaces
- lpr -P hp1_floor2 : hp1_floor2 is the printer name of the Linux/UNIX printer queue
To print the man page with effects such as italic and bold fonts on the HP Laser Jet printer, enter:
$ zcat /usr/share/man/man1/ls.1.gz | groff -man -Tps | lpr -P hp1_floor2
You can save man page as a ps file, enter:
zcat /usr/share/man/man1/ls.1.gz | groff -man -Tps >top.ps
Where,
- zcat : Open compressed /usr/share/man/man1/ls.1.gz file
- groff : Go through groff document formatting system, which is responsible for formatting of man page with effects such as italic and bold fonts on both screen and printer
- lpr -P hp1_floor2 : hp1_floor2 is the printer name of the Linux/UNIX printer queue
Here is a shell script that we have installed on all Linux workstations, it saves man page in a text file and later user can print it using lpr command.
#!/bin/bash # Linux shell script to save man pages to text file # so that later user can print them # Created by nixcraft <http://www.cyberciti.biz>, under GPL v2.0 or above. # ---------------------------------------------------------------------- CMDS="$@" OUTDIR="/tmp/$USER.man" [ ! -d "$OUTDIR" ] && mkdir -p "$OUTDIR" : for i in $CMDS do man "${i}" col -b > "$OUTDIR/${i}.txt" done echo "**********************************************************" echo "All man pages saved to $OUTDIR directory" echo "Just goto \"$OUTDIR\" directory and type the following command to print man page(s):" echo "lpr *.txt" echo "**********************************************************" exit 0
Just type the script-name followed by Linux commands, for example to print a man page of ls and bash type
$ saveman "ls bash"
Related: How do I print or make hard copies of Linux man and info pages?
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 2 comments… read them below or add one }
I tried this:
http://www.cyberciti.biz/tips/how-do-i-print-out-a-linux-man-or-info-page.html
I think:
man “${i}” col -b > “$OUTDIR/${i}.txt”
should be
man “${i}” | col -b > “$OUTDIR/${i}.txt”
and for (p)info pages how can I get the information into a pdf file?