Book: LPI Linux Certification in a Nutshell
Section: Chapter 16.  Text-Editing, Processing, and Printing (Topic 1.7)



16.3 Objective 3: Print Files

The lpr command ("line print") is used to send jobs to the lpd daemon for printing.

lpr

Syntax

lpr [options] [ files]

Description

Send files or standard input to a print queue. A copy of the input source is placed in the spool directory under /var/spool/lpr until the print job is complete.

Frequently used options

-#count

Send count copies of the print job to the printer.

-Pname

Specify the print queue name. In the absence of -P, the default printer is queried.

-s

Instead of copying a file to the print spooling area, make a symbolic link to the file instead, thereby eliminating transfer time and storage requirements in /var/spool/lpr for very large files.

Example 1

Print the file /etc/lilo.conf on the default print queue:

# lpr /etc/lilo.conf 

Example 2

Print a manpage by piping to lpr's standard input:

# man -t 5 printcap | lpr 

Example 3

Disable a print queue:

# lpc disable lp

Then attempt to print three copies of a file to the disabled queue as superuser:

# lpr -#3 /etc/lilo.conf 

Success, despite the disabled printer queue. Now try as a regular user:

$ lpr -#3 ~/resume.txt
lpr: Printer queue is disabled

As expected, normal users can't print to the disabled queue.

Objective 3 suggests that examinees should be familiar with the conversion of plain text (ASCII) files to PostScript format. One popular way to accomplish this is using the a2ps software package available from http://www.gnu.org/directory/a2ps.html. While not specifically required for Exam 102, a2ps can be helpful for creating formatted hardcopy of text and other files.

On the Exam

You must be familiar with lpr and its use with both files and standard input. Also remember that lpr doesn't send data to the printer, but to lpd, which handles sending it to the printer.