1. Context 9 Print Filters 1.107.4 2 5 6 10 License of this document 1.107.4 Install and configure local and remote printers Weight 1 Linux Professional Institute Certification — 102 1 Context Topic 107 Printing [3] 1.107.2 Manage printers and print queues [1] 1.107.3 Print files [1] Andrew Eager Geoff Robertson Nick Urbanik This document Licensed under GPL—see section 10 1.107.4 Install and configure local and remote printers [1] 2 Objective 2005 July Outline Description of Objective Candidates should be able to install a printer daemon, install and configure a print filter (eg apsfilter, magicfilter). This objective includes making local and remote printers accessible for a linux system, including postscript, non-postscript and samba printers. Key files, terms, and utilities include: lpd The Printing daemon Contents 1 2 3 4 5 Context Objective Resources Overview of Linux Printing Setting up a Printer 2 2 2 3 3 4 4 5 5 /var/spool/lpd/* — Spooler directories /etc/printcap — lpd Configuration file /etc/apsfilter/* /var/lib/apsfilter/* /etc/magicfilter/* 3 Resources 6 /etc/printcap file 6.1 printcap file syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 8 spool dir and log file Access Control Resources of interest Printing-HOWTO Printing-Usage-HOWTO www.linuxprinting.org 4. Overview of Linux Printing 1.107.4 3 6. /etc/printcap file 1.107.4 4 4 Overview of Linux Printing • There are several packages available for linux printing: – LPR – LPRng – Cups • Previously LPR (or LPRng) was the default on most Linux distros. . . • . . . but now Cups is the default. • Major components of the LPR subsystem are: – lpd — The printing daemon – lpr — A tool to submit jobs into the queue – lprm — A tool to remove jobs from the queue – lpq — A tool to view jobs in the queue – lpc — An administration tool for printers and queues • The commands in red are also provided by Cups. 6 /etc/printcap file Linux Printing printcap — The configuration file /etc/printcap contains information about all printers on the system (including remote printers) An example looks like: HPLjet|lp|lp0:\ :ml=0:\ :mx=0:\ :sd=/var/spool/lpd/HPLjet:\ :sh:\ :lp=/dev/lp0:\ :lf=/var/spool/lpd/HPLjet/log:\ :if=/usr/share/printconf/util/mf_wrapper: 6.1 printcap file syntax printcap — The configuration file Key points to note about printcap format: • Comments start with a ’#’ • Any line not starting with a colon or pipe is the start of a printer definition • Each line of a definition ends in a backslash except the last line 5 Setting up a Printer Installing a Printer • There are two ways to install a printer under Linux: • The easy way! — Use a GUI like printtool or system-config-printer on Fedora systems. • The hard way: – Edit /etc/printcap – Create the spool directory – Touch the log file – Restart lpd • lpd must be restarted each time /etc/printcap is edited • Spool directory and log file need to be created manually – it is not created automatically by LPD printcap — The configuration file if Define the input filter lf Define the printer log file lo Define the lock file created when printer is in use mx Define the maximum size of a print job rm Specify printer is on remote machine. Eg :rm=192.168.222.254: rp Define remote printer name. Eg :rp=HPLjet: sh Tell lpd not to print banner pages sd Specify spool directory 7. spool dir and log file 1.107.4 5 10. License of this document Key Point Summary 1.107.4 6 7 Creating spool directory and log file Creating spool directory and log file The spool directory should be owned by user lp and have permissions set to 700: • $ sudo mkdir /var/spool/lpd/HPLjet ← • $ sudo chown lp:lp /var/spool/lpd/HPLjet ← • $ sudo chmod 0700 /var/spool/lpd/HPLjet ← The log file should have permissions set to 660 and have the same ownership as the spool directory: • $ sudo touch /var/spool/lpd/HPLjet/log ← • $ sudo chown lp:lp /var/spool/lpd/HPLjet/log ← • $ sudo chmod 0660 /var/spool/lpd/HPLjet/log ← • Most Linux systems previously used LPR (or LPRng), • but now most Linux systems use Cups • Local & remote printer configs are stored in /etc/printcap • The print spool directory & log file must be created manually • Print access is controlled using /etc/hosts.lpd • Print filters convert different data types to a language understood by the printer • The lpd daemon is responsible for getting jobs from the user, putting them through the filter and delivering them to the spool directory. Key Point Summary • The lpc program is used to control the printer and print spools • The lpq program is used to view the print queues • The lprm program is used to remove jobs from the queues • The lpr program is used to submit jobs into the queue. 8 Access Control • Printer access is controlled through /etc/hosts.lpd • If the file does not exist, all access is granted • If the file exists, only those in the list will be granted access • The format is: [host [user]] Controlling printer access 10 License of this document License Of This Document Copyright c 2005, 2002 Andrew Eager , Geoffrey Robertson , Nick Urbanik . You can redistribute modified or unmodified copies of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation—either version 2 of the License or (at your option) any later version. Example: All access from box2.c222, only greg from box3.c222 box2.c222 box3.c222 greg 9 Print Filters • A print filter converts data to be printed into a language that your printer understands • There are several print filter packages: – Foomatic – Apsfilter – Magicfilter Print Filters