Team LiB
Previous Section Next Section

No-GUI Printer Administration

You don't need a GUI to administer CUPS printing in Fedora Core. In fact, some administrators don't even put GUIs on their servers. Even though many consider graphical administration interfaces to be more intuitive, some hard-core administrators will tell you that GUIs are for wimps. This section describes tools you can use to configure, tune, and troubleshoot printers from the command line.

Note 

If you make changes to printer configuration files directly from the command line, you risk having these values overwritten the next time you use a GUI tool to edit that file. In general, you should use one interface and stick with it if possible.

Table 14-1 shows a list of commands and configuration files that you can use to administer printing from a command-line shell.

Table 14-1: Linux Printer Commands and Files

User Printing Commands

lpr

Command to send print jobs (documents) to a printer:

lpr file-Sends to the default printer

lpr -P printer1 file-Sends file to printer1

man cupsd | lpr-Pipes cupsd man page to printer

lpoptions

As a regular user, list or change options that apply to your print jobs for selected printer. Options are stored in your $HOME/.lpoptions file:

lpoptions -p printer1-Shows options for named printer

lpoptions -o cpi=12 -p printer1-Changes cpi (characters per inch) value to 12 on printer1

lpq

List documents that are in the queue to be printed:

lpq -P printer1-Shows if printer 1 is ready to print and has print jobs waiting

lpq a-Shows queued jobs on all printers

lprm

Remove any of your own print jobs from the queue:

lprm-Cancels the current print job on default printer

lprm--P printer1-Cancels all print jobs for user on printer1

lprm 74 -P printer1-Cancels print job #74 on printer1 (Use lpq to see print job numbers)

lpstat

Show status of printers. You can add a printer name after each of the following examples to list just for that printer:

lpstat -a-Lists available printers and tells how long they have been accepting requests

lpstat -d-Shows default printer destination

lpstat -o-Shows all jobs queued to be printed

lpstat -p-Shows whether or not printers are enabled

lpstat -s-Shows summary of all printer status

Administrative Printing Commands

cupsconfig

Open CUPS graphical administrative interface (equivalent to typing http://localhost:631 in a web browser window)

cupstestppd

Testa ppd file before you install it: cupstestppd filename.ppd

disable

Temporarily disable a printer. Jobs can still be queued, but will not be sent to the printer until re-enabled: disable printer1

/usr/bin/enable

Re-enable a printer that is disabled (use full path, so as not to conflict with enable shell built-in): /usr/bin/enable printer1

lpoptions

Change options for a selected printer and set them as system defaults. Options are stored in the /etc/cups/lpoptions file

reject

Reject attempt to send documents to a printer queue (use lpstat - a to check this status):

reject printer1-Rejects jobs sent to printer1

accept

Begin again to accept jobs to selected printer (use lpstat - a to check this status):

accept printer1-Accepts jobs sent to printer1

cupsaddsmb

Configure a printer client for Samba. See Chapter 15 for details about this command and general Samba printer sharing.

lpadmin

Configure print queues

lpinfo

List CUPS devices and drivers:

lpinfo -v-Lists devices to which printers can be connected (serial, parallel, usb, and so on)

lpinfo -m-Lists all printer drivers available

Printer Configuration and Log Files

/var/log/cups/error_log

See the activities of the cupsd daemon. Good place to look to see what values are being sent to the cupsd daemon if you are debugging printing problems

/var/log/messages

General Linux message file. Contains information about starting and stopping the CUPS service

/var/log/cups/access_log

Lets you view messages describing when print jobs were sent and who sent them

Note 

In Table 14-1, I assume that you are running administrative commands as the root user. In a few cases, commands are duplicated in user and administrative sections. In these cases, running the command as root will impact the whole system (that is, it will change options for all users). These same commands run by regular users will effect only that user's printing options and jobs.

Adding a Printer with lpadmin

If you plan to skip the GUI interfaces, you need to use the lpadmin command to add a printer. Here's an example:

   // lpadmin -p printer1 -v parallel:/dev/lp0 -m deskjet.ppd

In this example, we added a printer named printer1 that is connected to the first parallel port on the computer ( /dev/lp0). The PPD file used for this printer is deskjet.ppd. You can find PPD files in the /usr/share/cups/model/ directory.

To delete the printer at a later time, use the -x option:

   # lpadmin -x printer1

   Adding a printer class with lpadmin

To keep one printer from getting too backed up, you can create printer classes. By adding several printers together in a class, print jobs can be distributed across a group of computers. Here is an example:

   # lpadmin -p printer1 -c myclass
   # lpadmin -p printer2 -c myclass

The first command creates the printer class named myclass and adds printer1 to that class. The second command adds the printer named printer2 to that class. To see all the members of that class, issue the command

   # lpstat -s
   system default destination: printer1
   members of class myclass:

           printer1
           printer2

Then, to send a print job so that the job goes to one of the printers in the class, you could simply use the class name instead of the printer name, as in

   # lpr -P myclass file1.ps

Team LiB
Previous Section Next Section