Home Blog Certs Knowledge Base About

LPIC-1 108.4 โ€” Manage Printers and Printing

Exam weight: 2 โ€” LPIC-1 v5, Exam 102

What You Need to Know

From the official LPIC-1 objectives:

  • Basic CUPS configuration (for local and remote printers).
  • Manage user print queues.
  • Troubleshoot general printing problems.
  • Add and remove jobs from configured printer queues.

Key files and commands: CUPS configuration files, /etc/cups/, /var/log/cups/, lp, lpr, lpq, lprm, lpstat, lpadmin, cancel, cupsenable, cupsdisable, cupsreject, lpmove.


CUPS โ€” Common Unix Printing System

CUPS (Common Unix Printing System) is the standard printing system on modern Linux. The daemon is cupsd.

CUPS Configuration Files

FileDescription
/etc/cups/cupsd.confMain CUPS daemon configuration
/etc/cups/printers.confConfigured printers (do not edit while CUPS is running)
/etc/cups/ppd/PPD (PostScript Printer Description) files for each printer
/etc/printcapLegacy LPD compatibility file, generated by CUPS

To enable the web interface, add to cupsd.conf:

WebInterface Yes

Web Interface

CUPS provides a web interface at http://localhost:631 for managing printers and jobs.

Log Files

FileDescription
/var/log/cups/access_logHTTP requests to the CUPS web interface
/var/log/cups/page_logEach page printed
/var/log/cups/error_logDaemon errors and warnings

lpadmin โ€” Configure Printers

lpadmin adds, modifies, and removes printers.

OptionDescription
-p NAMEPrinter name (used with add/modify)
-L "LOCATION"Human-readable location string
-v URIDevice URI (e.g., socket://192.168.1.100:9100)
-m MODELPPD model from the driver database
-x NAMEDelete the printer
-u allow:user / -u deny:userUser access control
-o option=valueSet printer option
# Add a network printer
lpadmin -p myprinter -L "Office 3B" -v socket://192.168.1.100:9100 -m drv:///sample.drv/laserjet.ppd

# Delete a printer
lpadmin -x myprinter

lpoptions โ€” Default Printer

lpoptions -d PRINTERNAME    # set system default printer

lpr โ€” Print Files (BSD Interface)

lpr submits files to a print queue.

lpr file.pdf
lpr -P laserjet file.pdf
OptionDescription
-P PRINTERSpecify destination printer
-# NPrint N copies
-o landscapePrint in landscape orientation
-o two-sided-long-edgeDuplex, flip on long edge (portrait)
-o two-sided-short-edgeDuplex, flip on short edge (landscape)
-o media=A4Paper size
-o collate=trueCollate copies
-o page-ranges=1-5Print page range
-o fit-to-pageScale to fit page
-o outputorder=reverseReverse output order

lp โ€” Print Files (System V Interface)

lp is the System V alternative to lpr.

lp file.pdf
lp -d laserjet -n 2 file.pdf
OptionDescription
-d PRINTERSpecify destination printer
-n NNumber of copies
-o option=valuePrinter-specific options (same as lpr -o)

lpstat โ€” Show Printer Status

lpstat -p           # list printers and their status
lpstat -d           # show default printer
lpstat -v           # show printer device URIs
lpstat -o           # show all print jobs
lpstat -a           # show acceptance status of all printers
lpstat -t           # show all status information

Managing Print Jobs

lpq โ€” Show Queue

lpq             # queue for default printer
lpq -a          # queues for all printers
lpq -P laserjet # queue for specific printer

lprm โ€” Remove Jobs

lprm 42         # remove job 42
lprm -          # remove all jobs for current user

cancel โ€” Cancel Jobs (System V)

cancel 42              # cancel job 42
cancel laserjet-42     # cancel using printer-jobid format

lpmove โ€” Move Jobs

lpmove laserjet-42 colorjet    # move job 42 from laserjet to colorjet

Managing Printer Queues

Reject and Accept

cupsreject prevents new jobs from being added to a queue (jobs already queued continue to print):

cupsreject laserjet
cupsaccept laserjet

Disable and Enable

cupsdisable stops a printer from processing jobs (queue continues to accept new jobs):

cupsdisable laserjet
cupsenable laserjet

Use both together to take a printer fully offline:

cupsreject laserjet    # stop accepting new jobs
cupsdisable laserjet   # stop processing existing jobs

Quick Reference

CUPS daemon: cupsd
Web interface: http://localhost:631

Config files:
  /etc/cups/cupsd.conf      main config (WebInterface Yes)
  /etc/cups/printers.conf   printer list (don't edit while running)
  /etc/cups/ppd/            PPD files
  /etc/printcap             legacy LPD compatibility

Log files:
  /var/log/cups/access_log  HTTP access
  /var/log/cups/page_log    pages printed
  /var/log/cups/error_log   errors

lpadmin:
  -p NAME   printer name     -L STR    location
  -v URI    device URI        -m MODEL  PPD model
  -x NAME   delete printer

lpoptions -d NAME    set default printer

lpr:
  lpr [-P printer] [-# N] [-o option] file
  Options: landscape, two-sided-long-edge, two-sided-short-edge,
           media=A4, collate=true, page-ranges=N-M,
           fit-to-page, outputorder=reverse

lp:
  lp [-d printer] [-n N] [-o option] file

lpstat:
  -p  printer status    -d  default printer
  -v  device URIs       -o  all jobs    -a  acceptance    -t  all

lpq [-P printer] [-a]   show queue
lprm ID                 remove job
lprm -                  remove all own jobs
cancel ID               cancel job
cancel PRINTER-ID       cancel by printer-jobid
lpmove PRINTER-JOB DEST move job to another printer

cupsreject NAME         stop accepting new jobs
cupsaccept NAME         start accepting new jobs
cupsdisable NAME        stop processing queue
cupsenable NAME         resume processing queue

Exam Questions

  1. What is the CUPS daemon called? โ†’ cupsd
  2. What file is the main CUPS configuration file? โ†’ /etc/cups/cupsd.conf
  3. Which CUPS config file should not be edited while CUPS is running? โ†’ /etc/cups/printers.conf
  4. What directive enables the CUPS web interface? โ†’ WebInterface Yes in cupsd.conf
  5. What is the URL for the CUPS web interface? โ†’ http://localhost:631
  6. What log file records each page printed by CUPS? โ†’ /var/log/cups/page_log
  7. What command adds a network printer named laserjet? โ†’ lpadmin -p laserjet -v socket://IP:9100 -m MODEL
  8. What command sets the default printer? โ†’ lpoptions -d PRINTERNAME
  9. How do you print 3 copies of file.pdf to a printer named office? โ†’ lpr -P office -# 3 file.pdf or lp -d office -n 3 file.pdf
  10. What lpr option prints in duplex (flip on long edge)? โ†’ -o two-sided-long-edge
  11. How do you check the print queue for all printers? โ†’ lpq -a
  12. What command removes all pending jobs for the current user? โ†’ lprm -
  13. What is the System V command to cancel a print job? โ†’ cancel JOBID or cancel PRINTER-JOBID
  14. What does lpmove laserjet-5 colorjet do? โ†’ Moves job 5 from the laserjet printer to colorjet.
  15. What is the difference between cupsreject and cupsdisable? โ†’ cupsreject stops new jobs from being added to the queue; cupsdisable stops the printer from processing jobs already in the queue.
  16. What command shows all printer statuses? โ†’ lpstat -p
  17. What command shows the default printer? โ†’ lpstat -d
  18. What file provides legacy LPD compatibility in CUPS? โ†’ /etc/printcap

Exercises

Exercise 1 โ€” Add a Printer

Add a printer named hplaser located in “Server Room” with device URI socket://10.0.0.5:9100.

Answer
lpadmin -p hplaser -L "Server Room" -v socket://10.0.0.5:9100

A PPD model (-m) would also be needed in practice to select the correct driver.


Exercise 2 โ€” Print with Options

Print page range 2โ€“4 of report.pdf in landscape to the office printer.

Answer
lpr -P office -o page-ranges=2-4 -o landscape report.pdf

Exercise 3 โ€” Queue Management

Take the printer laserjet fully offline: stop accepting new jobs and stop processing existing ones.

Answer
cupsreject laserjet
cupsdisable laserjet

Exercise 4 โ€” Move a Job

Job 7 is stuck on printer oldjet. Move it to newjet.

Answer
lpmove oldjet-7 newjet

Exercise 5 โ€” Check and Clear Queue

Show the queue for the default printer, then remove all your own pending jobs.

Answer
lpq
lprm -

LPIC-1 Study Notes | Topic 108: Essential System Services