Quick Links

Unlike a typical Windows machine, the little Raspberry Pi running Rasbian doesn't exactly come with plug-'n-play printer support. Read on as we show you how to add full-fledged print capabilities to your Pi unit.

Why Do I Want to Do This?

If you're experimenting with the Pi as a desktop replacement, want to enable a physical print output for a program or application suite you're using, or otherwise want to enable traditional printing on your Pi, this tutorial is a straight shot from printerless to happy printing; there's no previous printer-wrangling under Linux experience required.

Related: Build an LED Indicator with a Raspberry Pi (for Email, Weather, or Anything)

What Do I Need?

For this tutorial you'll need the following things:

  • 1 Raspberry Pi unit with Rasbian installed
  • 1 USB-based or network-accessible printer

If you haven't yet configured your Raspberry Pi with a Rasbian image, we highly suggest starting with our introduction to the Raspberry Pi.

Installing CUPS on the Pi and Enabling Remote Access

In order to link a printer with the Raspberry Pi, we first need to install Common Unix Printing System (CUPS). It's time to fire up your Pi and navigate to the terminal (either on the Pi itself of via SSH).

At the terminal, enter the following command to begin installing CUPS:

         sudo apt-get install cups
    

When prompted to continue, type Y and press enter. CUPS is a fairly beefy install, so feel free to go grab a cup of coffee. Once the base installation is complete, we need to make a few small administrative changes. The first order of business is to add ourselves to the usergroup that has access to the printers/printer queue. The usergroup created by CUPS is "lpadmin". The default Rasbian user (and the user we're logged into) is "pi" (adjust the following command accordingly if you want a different user to have access to the printer).

At the terminal enter the following command:

        sudo usermod -a -G lpadmin pi
    

For the curious, the "-a" switch allows us to add an existing user (pi) to an existing group (lpadmin), specified by the "-G" switch.

Related: How to Turn a Raspberry Pi into a Low-Power Network Storage DeviceOur final bit of pre-configuration work is to enable remote editing of the CUPS configuration. The rest of the configuration can be completed via the web browser on the Pi, but if you're not actually sitting right at the Pi and would prefer to use, say, the browser on your Windows desktop to complete the configuration, you'll need to toggle a small value in 

        /etc/cups/cupsd.conf
    

. At the terminal, enter the following command:

        sudo nano /etc/cups/cupsd.conf
    

Inside the file, look for this section:

        # Only listen for connections from the local machine
Listen localhost:631

Comment out the "Listen localhost:631" line and replace it with the following:

        # Only listen for connections from the local machine
# Listen localhost:631
Port 631

This instructs CUPS to listen for any contact on any networking interface as long as it is directed at port 631.

Scroll further down in the config file until you see the "location" sections. In the block below, we've bolded the lines you need to add to the config:

        < Location / >
    
        # Restrict access to the server...
    
        Order allow,deny
    
        <strong>Allow @local</strong>
    
        < /Location >
    
         
    
        < Location /admin >
    
        # Restrict access to the admin pages...
    
        Order allow,deny
    
        <strong>Allow @local</strong>
    
        < /Location >
    
         
    
        < Location /admin/conf >
    
        AuthType Default
    
        Require user @SYSTEM
    
         
    
        # Restrict access to the configuration files...
    
        Order allow,deny
    
        <strong>Allow @local</strong>
    
        < /Location >
    

The addition of the "allow @local" line allows access to CUPS from any computer on your local network. Anytime you make changes to the CUPS configuration file, you'll need to restart the CUPS server. Do so with the following command:

        sudo /etc/init.d/cups restart
    

After restarting CUPS, you should be able to access the administration panel via any computer on your local network by pointing its web browser at http://[the Pi's IP or hostname]:631.

Adding a Printer to CUPS

When you first navigate to http://[the Pi's IP or hostname]:631, you'll see the default CUPS homepage, as seen in the screenshot above. The section we're interested in is the "Administration" tab. Click on it now.

Within the Administration panel, click add printer. If you receive a warning about the site's security certificate, go ahead and click proceed anyway to ignore it. You'll be prompted to enter a username and password.

Go ahead and enter the username and password of the account you added to the "lpadmin" group earlier in the tutorial (e.g. if you're using a default Raspbian install, the login/password is "pi"/"raspberry"). Click "Log In".

After logging in, you'll be presented with a list of discovered printers (both local and networked). Select the printer you wish to add to the system:

After selecting the printer, you'll be offered an opportunity to edit the name, description, and location of the printer, as well as enable network sharing. Since our printer is already a network printer, we left "Share This Printer" unchecked:

After editing the printer name and adding a location, you'll be prompted to select the specific driver you want to use for your printer. Despite the fact that it automatically discovered the printer and the printer name, CUPS makes no attempt to pick the right driver for you. Scroll until you see a model number that matches yours. Alternatively, if you have a PPD file for the printer that you have downloaded from the manufacturer, you can load that with the "Choose File" button:

The last configuration step is to look over some general print settings like what you want the default printer mode to be, the default paper source/size, etc. It should default to the correct presets, but it never hurts to check:

After you click "Set Default Options", you'll be presented with the default administration page for the printer you just added to the CUPS system:

Everything looks good. The real test, however, is actually printing something. Let's fire up Leafpad, Rasbian's default text editor, and send a message:

While we realize it's a bit premature to write "huge success" on our test print before, you know, it's actually printed, we were that confident. Fifteen seconds or so later, the document came rolling out of the printer and dropped into the tray. Success!


At this point, if you've added the only user that needs access to the printer to the "lpadmin" group and you've added the only printer you want to access to the CUPS system, you're done. If you have any other users you would like to add or additional printers, simply run through the respective steps in the tutorial again to do so.