Previous Section  < Day Day Up >  Next Section

Recipe 14.2. Installing a Printer on a Standalone Linux PC

14.2.1 Problem

You need to connect a printer to your Linux PC.

14.2.2 Solution

If you have a USB printer, it must be connected and powered up at boot time.

First, make sure that the CUPS daemon is running:

$ lpstat -t

scheduler is running


If it is not running, it says:

$ lpstat -t

lpstat: Unable to connect to server: Connection refused

If that is the case, start it with its init script:

# /etc/init.d/cupsys start

On Red Hat and Fedora, use:

# /sbin/service cups restart

The easiest way to install a new printer is with the CUPS web interface. Type the CUPS URL in any browser:


You'll need the root password. Click the Printers tab, then click "Add printer," which opens the Admin menu. There are three values to enter here:

Name: hp6L

Location: room-202

Description: bw-laser

Choose the name carefully—CUPS needs this name, and changing it will cause problems. Your printer name will be used on the next few configuration pages. I've entered "hp61" for my Hewlett-Packard LaserJet6L printer. The Location and Description are optional.

On the next page, define the "Device for <printername>." This means the physical connection: parallel port, USB, SCSI, serial port, or network. Select your deviceURI from the drop-down menu. In this example, that is "Parallel port #1 Hewlett-Packard HP LaserJet6L."

On the "Model/Driver for <printername>" menu, scroll to the model number of your printer, and select a driver from the list.

Now it should say "Printer <printername> has been added successfully." Click on the printer name to go the printer's control page, and print a test page. Your CUPS page should look like Figure 14-1.

Figure 14-1. CUPS page

14.2.3 Discussion

If you prefer the command line, this long command does the same thing as the above example:

# lpadmin -p hp6L -L room-202 -D bw-laser -E -v parallel:/dev/lp0 \

-m HP-LaserJet_6-hpijs.ppd

Here are some definitions:

lpadmin -p

Set the printer name.


Set the printer location.


Describe the printer.


Enable the printer and make it ready to receive jobs.


Set the device URI.


Specify which driver (PPD file) to use. Note that the filepath is hardcoded into CUPS; if you try to use a filepath like /usr/share/cups/model/laserjet.ppd, it will fail, saying "lpadmin: add-printer (set model) failed: server-error-internal-error." Just use the PPD name, and make sure the PPD file you want is in /usr/share/cups/model/.

If you have Gimp-Print and Foomatic installed (if you don't you probably should) you'll find additional PPDs in /usr/share/cups/model/gimp-print and /usr/share/cups/model/foomatic. They are compressed:


You'll need to uncompress the file and move it to the /usr/share/cups/model directory:

# gunzip HP-LaserJet_6-hpijs.ppd.gz && mv HP-LaserJet_6-hpijs.ppd  \


It is not necessary to uncompress and move PPD files when you install printers using the CUPS web interface. Generic drivers

These are the generic drivers that come with the free version of CUPS:

$ ls /usr/share/cups/model

epson24.ppd   laserjet.ppd  pxlcolor.ppd  stphoto.ppd   deskjet.ppd   epson9.ppd   

okidat24.ppd  pxlmono.ppd   stphoto2.ppd   deskjet2.ppd   okidata9.ppd  stcolor.ppd   

dymo.ppd   pcl-6.ppd   stcolor2.ppd

If you can't find a driver specific to your printer, one of these should work. (You did check your distribution's hardware compatibility list, or the database on, before purchasing the printer, right?)

14.2.4 See Also

  • This chapter's "Introduction," for more information on printer drivers

  • CUPS Software Administrators Manual (http://localhost:631/documentation.html)

    Previous Section  < Day Day Up >  Next Section