Linux printing how to

Linux 101: Printing

To most users the system of printing on a PC is a simple, point-and-click process that should be automatically set up upon first use and does but one thing and one thing only – enables a PC to print. This is typically the case, and when printing with a Windows machine this system is often complimented by the installation of a piece of software written specifically for the printer to be used. Even if the printer was not set up and configure upon purchase, all the end user needs to do is insert the included CD (that came with the printer), install the software, plug in the printer, and begin printing.

With Linux this task may or may not be as simple. New Linux end users are often surprised to find out that, out of the box, many printers are already supported by their operating system. For those printers that are not supported out of the box, sometimes getting one to work is just a matter of finding the right driver to install. Sometimes, to the dismay of the user, their printer is not supported. Fortunately the latter scenario is becoming more and more rare.

But even with Linux printing becoming easier and easier to set up, it’s always good for the new user to see how they can install their new printer on a Linux box and begin printing. Now, if you understand how many and varied the Linux flavors are, you will understand how imposing of a task it would be to cover all possible printer configuration systems. Fortunately the Common Unix Printer Service (CUPS) offers a web-based, universal set up tool that is found on all distributions that use CUPS for printing.

In this tutorial you will be introduced to CUPS and see how to setup a printer for a Linux desktop machine. 


What is CUPS? 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:

  • Print spooler/scheduler: Lines up printing jobs to be sent to the printer.
  • Filter system: Converts data so that the attached printer can understand and format the data being printed.
  • Backend system: Transports data from filters to printer.

The flow of data looks like that shown in Figure 1. As you can see application (, Firefox, Evolution, Nano, etc.) sends its data to the scheduler, which then begins the CUPS process.

By default cups installs the following directories:

  • /etc/cups: Configuration directory.
  • /var/spool/cups/: The spooler directory where print jobs are held for printing.
  • /var/spool/cups-pdf: The spooler directory where CUPS-generated PDF files are held for printing.

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:

Stopped with the command:

And restarted with the command:

For the basic usage that is really all you would need to know. Of course the next step is to understand how to set up your printer. As I said earlier, because each distribution contains different tools for printer setup, I am going to demonstrate this process with the integrated CUPS web-based tool. This knowledge should easily translate over to your distributions’ set up tools.

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. A typical PPD file will look like this file for a Samsung ML-1710. 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.¬†

Читайте также:  Linux свернуть все окна команда

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 (see Figure 2). 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 ptiner.

That’s it. Now let’s examine each step more closely.

Step 1

From the main page click Add Printer button. You will also notice a Manage Printers button. From that screen you can manage all printers that have already been added.

Step 2

There are three pieces of information that you need to enter in this window (see Figure 3):

  • Name: This is the name of the printer that can not include the characters “#”, “/”, or a SPACE. In my case, for the Samsung ML-1710, I could enter SamsungML1710.
  • Location: This is a description where the printer is located. This is just for ease of management. And human-readable characters are valid.¬†
  • Description: A human-readable description of your printer. This can contain spaces.

Once you have filled out all of this information, click Continue to move to the next step.

Step 3

In this window (see Figure 4) you are going to select the Device URI for the printer. This will most likely fall under one of two categories: local or remote. If the printer is local it will be listed in the drop down, so all you need to do is select that printer. If the printer is remote (as we are going to setup – since it is the more difficult process). Since I am going to illustrate using a remote printer, I will select the Internet Printing Protocol as my Device URI.

Once you have selected the proper URI click the Continue button to move on to the next step.

Step 4

In the next window (see Figure 5), since we are configuring a remote printer, you will need to enter the address of the printer. In the case of my remote printer I knew before hand that the printer in question was located in the /printers/ spool and was called LaserPrinter. If you are connecting to a printer server, you will need to know this information.

Obviously the CUPS system offers you examples of the types of URI addresses that are valid. Even though you have already instructed CUPS that you are using ipp (from the previous window), you still have to include the ipp:// section of the address for your remote printer. Without that your machine will not be able to connect to the remote printer.

After you have entered the address click Continue to move on to the next step.

Steps 5 and 6

In these two steps you only need to select the Manufacturer (Step 5) and the Model (Step 6) of your printer. Pay close attention when selecting your Model because there might be different selections for different languages. So choose the proper language. If you do not find your Model for your printer then you might have to install a driver for it. In my case (for the Samsung ML-1710) I had to go back and install the Splix driver. To do this I followed these steps:

  1. Open up Synaptic
  2. Search for “splix” (no quotes).
  3. Install the resulting application.
Читайте также:  Как установить принтер brother hl 1110r без установочного диска на компьютер

The SPLIX package is the driver package for Samsung SPL2 and SPLC laser printers.

If your printer is not a Samsung, and it does not appear in the Model selection, you might need to search for either a proprietary driver or a compatible driver. Google is your friend.

Once you have completed this step you can click the Add Printer button to add your printer. Most likely you will be asked to enter your administrator username and password. When that authentication succeeds a new page will open up (see Figure 6) that allows you to further configure your printer. This page is really only necessary if you have specific needs from your printer. If you do not need to refine your configuration you can close out the CUPS web interface and begin using your printer.

Final Thoughts

Congratulations, you just set up your printer on a Linux machine. Of course this walk-through instructed you how to set up a remote printer. The reason for this is that the remote printer setup has a few more steps to complicate the issue, so knowing how to accomplish this will make configuring a local printer a snap.

And even if your distribution has a tool specific for printer configuration, you can still use the CUPS web-based interface for this job. In some ways this tool is much easier to use. 


Linux printing how to

This section discusses how to print files, examine the print queue, remove jobs from the print queue, format files before printing them, and configure your printing environment.

The Linux printing system—the lp system—is a port of the source code written by the Regents of the University of California for the Berkeley Software Distribution version of the UNIX operating system.

By far, the most simplistic way to print in the Linux operating system is to send the file to be printed directly to the printing device. One way to do this is to use the cat command. As the root user, one could do something like

In this case, /dev/lp is a symbolic link to the actual printing device—be it a dot-matrix, laser printer, typesetter, or plotter. (See ln (1) for more information on symbolic links.)

For the purpose of security, only the root user and users in the same group as the print daemon are able to write directly to the printer. This is why commands such as lpr , lprm , and lpq have to be used to access the printer.

Because of this, users have to use lpr to print a file. The lpr command takes care of all the initial work needed to print the file, and then it hands control over to another program, lpd , the line printing daemon. The line printing daemon then tells the printer how to print the file.

When lpr is executed, it first copies the specified file to a certain directory (the spool directory) where the file remains until lpd prints it. Once lpd is told that there is a file to print, it will spawn a copy of itself (what we programmers call forking). This copy will print our file while the original copy waits for more requests. This allows for multiple jobs to be queued at once.

The syntax of lpr (1) is a very familiar one,

If filename is not specified, lpr expects input to come from standard input (usually the keyboard, or another program’s output). This enables the user to redirect a command’s output to the print spooler. As such,

Читайте также:  Как печатать на принтере канон с компа

The lpr command accepts several command-line arguments that allow a user to control how it works. Some of the most widely used arguments are: — P printer specifies the printer to use, — h suppresses printing of the burst page, — s creates a symbolic link instead of copying the file to the spool directory (useful for large files), and — # num specifies the number of copies to print. An example interaction with lpr might be something like

This command will create a symbolic link to the file thesis.txt in the spool directory for the printer named dj , where it would be processed by lpd . It would then print a second copy of thesis.txt .

For a listing of all the options that lpr will recognize, see lpr (1).

To view the contents of the print queue, use the lpq command. Issued without arguments, it returns the contents of the default printer’s queue.

The returned output of lpq can be useful for many purposes.

Another useful feature of any printing system is the ability to cancel a job that has been previously queued. To do this, use lprm .

The above command cancels all of the print jobs that are owned by the user who issued the command. A single print job can be canceled by first getting the job number as reported by lpq and then giving that number to lprm . For example,

would cancel job 31 ( thesis.txt ) on the default printer.

The lpc (8) program is used to control the printers that lpd serves. you can enable or disable a printer or its queues, rearrange entries within a queue, and get a status report on the printers and their queues. Lpc is mostly used in a setup where there are multiple printers hanging off one machine.

The above will start the lpc program. By default, this enters you into an interactive mode, and you can begin issuing commands. The other option is to issue an lpc command on the command line.

A list of the available commands are in the lpd man page, but here are a few of the major commands you’ll want to know about. Any commands marked with option can either be a printer name (lp, print, etc) or the keyword all , which means all printers.

  • disable option — prevents any new printer job from being entered
  • down option — disables all printing on the printer
  • enable option — allow new jobs to enter the print queue
  • quit (or exit) — leave lpc
  • restart option — restarts lpd for that printer
  • status option — print status of printer
  • up option — enable everything and start a new lpd

Just a quick note here on RedHat’s amazing printtool program. It seems to do everything that a magicfilter would do. RedHat already installs many of the programs to do the filtering. Here’s how I have my printer set up under RH 4.0 with an HP LJ 4L connected to my parallel port (should be the same for other versions of RH as well).

  • Become root and fire up printtool (if you su’ed, you remembered to SETENV DISPLAY :0.0 and xhost +, right?)
  • Click «Add», and hit «OK» for a local printer.
  • Fill in the printer device (/dev/lp1 for me)
  • Fill in the input filter — Select a printer type, resolution, and paper size (ljet4, 300×300, and letter)
  • Hit «OK» all the way back, and restart the lpd.

Just like rolling an /etc/printcap file by hand, you can have multiple printer definitions for each physical printer. One for different paper sizes, resolutions, etc.


Поделиться с друзьями