O'Reilly logo

Ubuntu Hacks by Bill Childers, Kyle Rankin, Jonathan Oxer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #9. Set Up Your Printer

Get that printer connected, up, and running with Ubuntu.

Ubuntu uses CUPS, the Common Unix Printing System, to manage printers and print queues. CUPS can be configured using a variety of tools, including the GNOME CUPS Manager and its own built-in web interface that runs on port 631.

GNOME CUPS Manager

To launch GNOME CUPS Manager, select System→Administration→Printing, which will display a list of currently installed printers, shown in Figure 1-6, and give you the option of adding a new printer.

GNOME CUPS Manager

Figure 1-6. GNOME CUPS Manager

Double-click the New Printer icon to open the "Add a Printer" window. Here, you need to specify whether your printer is connected directly to your computer or is on your network (see Figure 1-7). If your printer is connected by USB, it's a good idea to use the instructions in "Mount Removable Devices with Persistent Names" [Hack #83]">Figure 1-7). If your printer is connected by USB, it's a good idea to use the instructions in "Mount Removable Devices with Persistent Names" [Hack #83] to assign a permanent name to your printer before going any further; otherwise, it will probably be assigned a different bus ID every time you plug it in, and you will be asked to configure it again each time!

Specifying local or network printer

Figure 1-7. Specifying local or network printer

If your printer is connected via the network, you will need to specify the protocol: IPP (Internet Printing Protocol), SMB (Windows printer sharing), LPD (Line Printer Daemon), or HP JetDirect. Each of those protocols in turn provides a number of configuration options to specify the printer identity. In Figure 1-8, the printer is connected to the second port on a network print server using IPP.

Configuring a network printer

Figure 1-8. Configuring a network printer

Specify the printer manufacturer and then select the model from the provided list, as shown in Figure 1-9.

Selecting a printer model

Figure 1-9. Selecting a printer model

If your printer model isn't included in the list, you can try using one of the drivers listed under the Generic manufacturer, or, if it's a PostScript printer, you can load the manufacturer's supplied PPD (PostScript Printer Description) file using the Install Driver button.

Apply the changes, and you'll return to the list of installed printers with your new printer listed, as shown in Figure 1-10.

Printer added

Figure 1-10. Printer added

CUPS Web Interface

GNOME CUPS Manager provides quick access to basic options, but to really take control of CUPS, you should use the built-in web-management interface. Open your web browser and point it at http://localhost:631 to see a huge range of options.

Share Local Printers

You can allow other computers on your network to print to your locally connected printer by setting the Shared option.

Open /etc/cups/printers.conf in a text editor to see the definition for your printers. Each printer is defined in a separate block, with configuration options applied in any order inside the block, and you should see an existing configuration option of:

Shared no

Change this to:

Shared yes

After you make changes to printers.conf, restart the CUPS scheduler:

$ sudo /etc/init.d/cupsys restart

Apply Print Quotas

CUPS implements a very simple quota system that allows you to restrict page count over a specified period, but it can be applied only per printer and not per user.

Open /etc/cups/printers.conf in a text editor and add two options: PageLimit, which is the page count limit, and QuotaPeriod, which is the period in seconds for which you want it enforced. To apply a limit of 200 pages per week, you could set those options to:

QuotaPeriod 604800
PageLimit 200

One day is 86,400 seconds, a week is 604,800 seconds, and a month is 2,592,000 seconds.

You can also apply a KLimit option, which is the amount of data in kilobytes that the printer is allowed to receive. This can be useful if you want to prevent people sending extremely large print jobs to specific printers.

Tip

Remember to restart CUPS after making changes to printers.conf.

One possible hack to get around the per-printer limitation of quota settings is to configure the same printer multiple times, each with a different name and access controls but all communicating with the same device. The quota for each "printer" will then be tracked and enforced individually, so you could have each user connecting to a different virtual printer to enforce individual quotas.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required