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
| File | Description |
|---|---|
/etc/cups/cupsd.conf | Main CUPS daemon configuration |
/etc/cups/printers.conf | Configured printers (do not edit while CUPS is running) |
/etc/cups/ppd/ | PPD (PostScript Printer Description) files for each printer |
/etc/printcap | Legacy 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
| File | Description |
|---|---|
/var/log/cups/access_log | HTTP requests to the CUPS web interface |
/var/log/cups/page_log | Each page printed |
/var/log/cups/error_log | Daemon errors and warnings |
lpadmin โ Configure Printers
lpadmin adds, modifies, and removes printers.
| Option | Description |
|---|---|
-p NAME | Printer name (used with add/modify) |
-L "LOCATION" | Human-readable location string |
-v URI | Device URI (e.g., socket://192.168.1.100:9100) |
-m MODEL | PPD model from the driver database |
-x NAME | Delete the printer |
-u allow:user / -u deny:user | User access control |
-o option=value | Set 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
| Option | Description |
|---|---|
-P PRINTER | Specify destination printer |
-# N | Print N copies |
-o landscape | Print in landscape orientation |
-o two-sided-long-edge | Duplex, flip on long edge (portrait) |
-o two-sided-short-edge | Duplex, flip on short edge (landscape) |
-o media=A4 | Paper size |
-o collate=true | Collate copies |
-o page-ranges=1-5 | Print page range |
-o fit-to-page | Scale to fit page |
-o outputorder=reverse | Reverse 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
| Option | Description |
|---|---|
-d PRINTER | Specify destination printer |
-n N | Number of copies |
-o option=value | Printer-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
- What is the CUPS daemon called? โ
cupsd - What file is the main CUPS configuration file? โ
/etc/cups/cupsd.conf - Which CUPS config file should not be edited while CUPS is running? โ
/etc/cups/printers.conf - What directive enables the CUPS web interface? โ
WebInterface Yesincupsd.conf - What is the URL for the CUPS web interface? โ
http://localhost:631 - What log file records each page printed by CUPS? โ
/var/log/cups/page_log - What command adds a network printer named
laserjet? โlpadmin -p laserjet -v socket://IP:9100 -m MODEL - What command sets the default printer? โ
lpoptions -d PRINTERNAME - How do you print 3 copies of
file.pdfto a printer namedoffice? โlpr -P office -# 3 file.pdforlp -d office -n 3 file.pdf - What
lproption prints in duplex (flip on long edge)? โ-o two-sided-long-edge - How do you check the print queue for all printers? โ
lpq -a - What command removes all pending jobs for the current user? โ
lprm - - What is the System V command to cancel a print job? โ
cancel JOBIDorcancel PRINTER-JOBID - What does
lpmove laserjet-5 colorjetdo? โ Moves job 5 from thelaserjetprinter tocolorjet. - What is the difference between
cupsrejectandcupsdisable? โcupsrejectstops new jobs from being added to the queue;cupsdisablestops the printer from processing jobs already in the queue. - What command shows all printer statuses? โ
lpstat -p - What command shows the default printer? โ
lpstat -d - 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