Install a printer on Raspberry PI

Installing CUPS on the Pi and Enabling Remote Access

In order to link a printer with the Raspberry Pi, you first need to install Common Unix Printing System (CUPS). It’s time to fire up your Pi and navigate to the terminal.

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 takes a long time to install. More then 10 minutes. Once the base installation is complete, you 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 you’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 you to add an existing user (pi) to an existing group (lpadmin), specified by the “-G” switch.

Our 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, I have bolded the lines you need to add to the config:

< Location / >

# Restrict access to the server...

Order allow,deny

Allow @local

< /Location >


< Location /admin >

# Restrict access to the admin pages...

Order allow,deny

Allow @local

< /Location >


< Location /admin/conf >

AuthType Default

Require user @SYSTEM

# Restrict access to the configuration files...

Order allow,deny

Allow @local

< /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. E.G. http://192.168.178.44: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. The section I am 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. I made  “Share This Printer” checked, so it appears in every linux box on my network:

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 print a message:

Fifteen seconds or so later, the document came rolling out of the printer and dropped into the tray. Success!