Welcome to the latest edition of Ask the Geek. As I mentioned in my last column, this week we are going to start a series on using the Common Unix Printing System (CUPS), which can introduce a universal printing solution to your network.
The world of printing for Unix/Linux has not changed much in a very long time. We still use good old lpd (the line printer daemon), we don't have support for IPP (Internet Printing Protocol), and we still don't have the ability to use many printers. But that situation is changing, and quickly. A new product is making inroads into the printing arena.
The CUPS software provides a way for Unix/Linux users to manage printing in an efficient and reliable manner. It natively supports IPP and has interfaces for LPD, SMB (Server Message Block, i.e., printers attached to Microsoft Windows), and JetDirect. CUPS can provide network printer browsing and use PostScript printer description (PPD) files. In short, with CUPS you can run a printer on a Linux machine as easily as they can on a Windows machine, but with the power of Linux.
CUPS runneth over
That said, let's get our hands dirty. First, we need to acquire CUPS. If you're running Mandrake 7.2, you already have it. (Yes, a shameless recommendation; it's what I run on my home machine.) If you are running another distribution, however, you'll need to download it (see Resources for the distribution site).
Once you've downloaded CUPS, you'll need to remove your old printing software. I'll explain this process using a machine running Red Hat 6.2 as an example. On such a machine, you must remove lpr, printtool, and rhs-printfilters before you install CUPS. You will want to keep these packages handy, though, in case CUPS doesn't work for you. If CUPS isn't your cup of tea, you can reinstall the packages and continue to be productive.
To remove these packages, type:
rpm -e lpr printtool rhs-printfilters
Then, install CUPS by typing:
rpm -ivh cups-1.1.4-linux-2.2.14-intel.rpm
Be aware that your filename may differ slightly.
CUPS is now installed. You should see the following message:
cups: scheduler started
This lets you know that CUPS is running and awaiting print jobs.
You can administer CUPS either at the command line or via a Web-based administrator. We will start by adding a printer from the command line interface. As the root user, type:
/usr/sbin/lpadmin -p LaserJet -E -v parallel:/dev/lp0 -m laserjet.ppd
The above lpadmin syntax performs the following tasks:
- Adds a printer called LaserJet (
-p)
- Enables the printer to be used (
-E)
- Sets the device and device type to use (
-v)
- Uses the driver/PPD file
laserjet.ppd (-m)
Since we're at the command line, the quickest way to test the printer would be to type:
/usr/bin/lp -d LaserJet /etc/aliases
The above lp syntax will print to the LaserJet printer (-d) the file /etc/aliases. If the resulting output is your aliases file, then you're all set. Of course, this is the simplest configuration of CUPS that you can have.
You can also set the priority of the print job by using the -p flag. For example:
/usr/bin/lp -d LaserJet -p 90 /etc/aliases
By adding -p 90, you have stated that your print job has a priority of 90 out of 100. It will print before print jobs with a priorities lower than 90 -- including those with no priority set, as the default priority is 50.
A complete list of options for the lp command is available from the man page. They include what is shown above, plus some nice features like designating how many copies you would like printed.
Disable a printer
We have successfully added and tested a printer. What if we want to disable a printer? To do this, we would use the disable command:
/usr/bin/disable -r "Changing Paper" LaserJet
The above disable syntax will disable the printer LaserJet and will cite "Changing Paper" as the reason (-r) for its unavailability. The -r is a nice way to let people know what is going on with a printer.
Once you've finished changing the paper, you can re-enable the printer by using the enable command, like so:
/usr/bin/enable LaserJet
The next logical question: what if you don't have a LaserJet? The default installation of CUPS comes with drivers for HP and Epson printers. That pretty much covers the world of personal printers (sorry, Canon fans). If you don't have one of these brands, don't despair. You have two viable options. If you are a free-software-only fanatic, you can point your Web browser to the LinuxPrinting.org Website. Or, if you're less religious, you could purchase ESP Print Pro (see Resources).
The LinuxPrinting.org Website features printer drivers for many printers. It also includes a CUPS PPD file maker. Many printers require a PPD file. It was just my luck to pick the one printer that is not supported and is considered for all intents and purposes a paperweight -- yes, the HP LaserJet 3150.
ESP Print Pro is developed by Easy Software Products, the company that initiated the development of CUPS. I personally believe that it is important to support companies that provide good products. ESP Print Pro is CUPS with a pretty interface and support for over 2,300 printers. Unfortunately, for everything except the Linux standalone license, it's got a high price tag.
In short, CUPS is not difficult to configure, and the GPLd version comes with a Web-based configuration interface. The major advantage to the ESP Print Pro product is the huge number of printer drivers it includes. If you are a commercial shop, I would suggest first checking LinuxPrinting.org to see if your printer is supported. If not, I'd check out ESP.
In the next installment of Ask the Geek, we'll continue exploring CUPS, including some free graphical management interfaces (such as KUPS), the basics of security, and network printing. Until then, avoid rabid dogs and eat healthy!
Do you have a question that's been bugging you about Linux? Post it in the Ask the Geek discussion forum or send it to me by email. We just might feature it! See you in two weeks.
Resources