Printing in Linux

Printing in Linux relies primarily on the CUPS (Common UNIX Printing System) print server. Most modern distributions (like Ubuntu or Fedora) include this out-of-the-box and will automatically detect connected or network printers, offering a seamless setup through your desktop's graphical printer settings.

CUPS (Common Unix Printer Service)

CUPS is a modular printer system for the UNIX-like operating systems that serves as a print server. But don’t think that a print server is a network-only system. The CUPS system can act as a printer server for a local machine or a network of machines. This means with one system you can set up printing for a local machine or for a group of networked machines.

CUPS consists of:


By default cups installs the following directories:


CUPS also installs an executable binary in /etc/init.d/ (or /etc/rc.d/init.d) called cups. This binary is started with the command:

/etc/init.d/cups start

Stopped with the command:

/etc/init.d/cups stop

And restarted with the command:

/etc/init.d/cups restart

Printer Setup

When you set up a printer in UNIX, the configuration creates a Postscript Printer Description file (ppd). This file contains all of the descriptions of a printers’ features as well as the PostScript code used to invoke features for a print job for that printer. This ppd file will be created no matter which setup tool you use. Most likely you will not have to touch this file. There¬† have been a few occasions where I have had to take care of a couple of very minor changes to this configuration file. Those are very rare instances however.

Now, let’s move on to the actual configuration.

In order to configure your printer with the CUPS web-based tool you need to open up your web browser and point it to http://localhost:631. What will appear is the main page for the CUPS web-based tool. The set up of a printer is simple. Here are the steps:

  1. Click the Add Printer button.
  2. Enter the name, location, and description of the printer.
  3. Select the device.
  4. Enter the device URI (this instructs the backends where the printer is located).
  5. Select the Manufacturer of your printer.
  6. Select the Model of your printer.
  7. Configure any general settings for your printer.

Printing Files

CUPS provides both the System V (lp) and Berkeley (lpr) commands for printing:

lp filename
lpr filename

Both the lp and lpr commands support printing options for the driver:

lp -o media=A4 -o resolution=600dpi filename
lpr -o media=A4 -o resolution=600dpi filename

CUPS recognizes many types of images files as well as PDF, PostScript, and text files, so you can print those files directly rather than through an application.

If you have an application that generates output specifically for your printer then you need to use the -o raw or -l options:

lp  -o raw filename
lpr -l     filename

This will prevent the filters from misinterpreting your print file.