Automating CUPS with shell commands
Setting Up the Printer
To speak with a Kyocera FS-2000 network printer using its hostname, I added the entry 192.168.0.53 fs2000 to the /etc/hosts
file. Alternatively, you could transfer the address entry to a local name server. The command lpadmin
is used to set up the printer. The necessary settings are found in Table 3.
Table 3
Config Options for lpadmin
Switch | Action |
---|---|
-p <Name> |
Specify printer name |
-D "<Description>" |
Specify description of printer |
-E |
Activate printer or class |
-v <URI> |
Specify device URI |
-P /<path/to/printer>.ppd |
Specify PPD file |
-c <printer class> |
Assign printer to a class |
-x <printer> |
Delete Printer |
-o <option> |
Various options for per-user quotas; sets protocol |
-u allow:<user>,<user>,@<group> |
Permit user access |
-u deny:<user>,<user>,@<group> |
Deny user access |
-u allow:all |
Turn off user access control |
Referring to the following example,
# lpadmin -p <printer name>/<queue> -D "<description>" -L "<location>" -v <device URI> -P /<path/to/PPD>/<PPD file> -E
the name you enter for the printer with the -p
switch should be short and easy to remember. Ideally, the description added with the -D
switch has information about the specific printer model you are setting up. The -L
and -v
switches specify the printer location and device URI, and -P
requires the complete path specification to the PPD file (in /etc/cups/ppd/
).
The -E
switch corresponds to cupsenable
and cupsaccept
from the command line. (Additional information for controlling printers from the command line appears in the "Administering CUPS" section.) Once this switch activates the device, you can then perform a status request with lpstat -a
to check on all of the available printers.
If you were to assign the printer to a class that does not yet exist with the -c
option, CUPS would automatically create the class.
Settings
The lpoptions
command lets you create settings associated with the device. For example,
lpoptions -d <printer>
designates a particular printer as the default printer. Without the -d
option, the command outputs the device settings for the default printer.
Printer administration stores the system-wide printer settings under /etc/cups/lpoptions/
and settings for the individual user under ~/.cups/lpoptions/
. The relevant files contain, among other things, information about the default printer and, potentially, information for resolving print requests.
The -o <option>=<value>
switch specifies properties such as the separation page, the paper format, and continuous tone/duotone print, for example. To view all of the switches and options, you should call man lpadmin
and man lpoptions
.
« Previous 1 2 3 4 Next »
Buy this article as PDF
Pages: 6
(incl. VAT)