September 16, 2013 · cups debian hacks linux network printer printing raspberrypi raspi rpi server

CUPS Your Printer with Raspberry (or Any Other Linux Machine)

Shared Printer

I used to have a problem with my printing stuff out. Owing only a laptop that is moved all the time around the house and a printer that found it's slumber place in an area inconvenient for a laptop to be placed/connected/left for printing (and all the cables! oh, the cables!), I had to think of a more convenient way of comfortable printing. I've realised that I could be using the RasPi as a printing server! It's small, it already found it's place under the printer's desk, so why not connect them together?

To enable network printing from your Pi (or any other Linux machine), all you have to do is to install (and configure a bit) the most popular, I guess, open source printing system - CUPS. It's a system developed by Apple, bought by Apple from Easy Software Products in 2007 10 years after the software was first developed (!), for OS X and other UNIX-like operating systems. CUPS uses the Internet Printing Protocol (IPP) to support printing to local and network printers. So, here we go!


  1. The Installation
  2. The Initial Configuration
  3. Editing cupsd.conf
  4. Printing from command line
  5. Printing from other machine (Windows XP)
  6. Google Cloud Print

The Installation

To install CUPS you have to head to your terminal enter the following command:

sudo apt-get -y install cups

Once the installation is completed (it may take a while, so be patient, grab a coffee or go for a short walk), we have to add ourselves (the pi user for Raspbian) to the usergroup that has access to the printers/printer queue. The usergroup created by CUPS is lpadmin. We do so by typing:

sudo usermod -a -G lpadmin pi

The final thing to do before we start configuring the printer server itself, is to enable remote access to CUPS server. At the terminal, enter the following command:

sudo nano /etc/cups/cupsd.conf

Inside the file, we comment out (add # sign in front of a line) or delete a line:

Listen localhost:631

and replace it with:

Port 631

This instructs CUPS to listen for any contact on any networking interface as long as it is directed at port 631. Then, scroll further down in the config file until you see the location sections. In the block below, bolded lines are the one you need to add to the config:

# Restrict access to the server...
Order allow,deny
Allow @local 
# Restrict access to the admin pages...
Order allow,deny
Allow @local
AuthType Default
Require user @SYSTEM
# Restrict access to the configuration files...
Order allow,deny
Allow @local

Exit the file saving changes ([Ctrl] + X, [Ctrl] + Y, [Enter]).Any time you make changes to the CUPS configuration file, you'll need to restart the CUPS server. Do so with the following command:

sudo service 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 https://the.pi.ip.address:631(if you don't know what your Pi's IP address is, you can check it by typing sudo ifconfig, and looking at a line that starts with <strong>inet addr</strong>).

The Initial Configuration

You'll now need to add a printer by using the web interface. Assuming you've already connected the printer to your Raspberry, head to https://the.pi.ip.address:631 in your web browser. If your server is started, a page should load with links to various tasks. Click the first link Do Administration Tasks. A dialog will pop up asking for username and password. You need to log in as root and use your root password to access the administration menu (for Raspbian, insert your username and password here)

Once logged in, click add printers and follow the prompts to set up your printer. 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.

Next, 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.

If you cannot find your printer there (as it was in my case), you'll have to search for your printer drivers on the Internet (or get them from installation disk if you have one). You need to find PPD file for the printer (in most cases available for download at manufacturer's webpage, do don't worry).  Once you've found the PPD for your printer, 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.

When the printer is added, click on the "Configure Printer" to set page size and printing quality. Finally, click "Print Test Page". If that works, head on, if not, try to change configuration of the printer until it works. In my case, although I have a Canon Pixma MP230, I had to chose a driver for Pixma MP250 to make it work!.

Editing cupsd.conf

Open the cupsd.conf file once again:

sudo nano /etc/cups/cupsd.conf

You will me making only small modifications to this file. First and foremost, look for the line that looks something like this:


If it's not there, add it. Note the #. Delete this to uncomment the line. You may either put in your hostname or the static ip address you assigned earlier. The line should look like this:

ServerName 192.168.x.x

Adjust it to point to your RasPi IP address.

The second adjustment you will make is to the line that looks like this:

BrowseAddress @LOCAL

It needs to look like this:


This should your broadcast for your entire network. Adjust the 255 to whatever your netmask is.

Finally look for this section of the file:

Order Deny,Allow
Deny From All
Allow From

Create a new line after Allow From and add the ip addresses or ranges for your network. The <location></location> section should look like this when you are done (the new line is in bold red):

Order Deny,Allow
Deny From All
Allow From
Allow From 192.168.1.*

You should adjust this line according to your network address setup. For example, my network has static ips so I just added the ip address for the client, or networked computer. In networks with many more clients, this is a hassle, so doing the above is more friendly. Save the file and restart the cups server.

Using command line for printing

If you're not using desktop environment on your Raspberry Pi (or any other Linux machine), you are still able to access your printer and make it print something. Here are some useful commands to use in terminal:

  • Check if the printer is running

lpstat -r

  • Check default printer

lpstat -d

  • Printer queue


  • Print a file

lp filename

Using Your Raspberry Printer on Windows

Below are the steps required for connecting to a working printer on a network and print to it.

  1. Open the Windows Control Panel
  2. Double-click the "Printers" or "Printers and Faxes" icon.
  3. Double-click the "Add a printer" icon.
  4. Once in the Printer Wizard click the Next button to get started.
  5. Select either "A network printer, or a printer attached to another computer" or "Network Printer" and click Next.
  6. Type the name of the printer's network address. This will be the name of the computer and then the name of the printer. The network path for our printer would be: \\192.168.x.x:631\printers\printer_name. If you are adding the printer on a Microsoft Windows XP computer you can click the Browse icon to browse your network and locate the printer.
  7. Once the path has been typed in click Next.
  8. If the printer was located over the network Windows should either install the printer or you may be required to install the drivers for that printer on the computer before completing the installation. If you no longer have the software or drivers for your printer you can get them from your printer manufacturer.

It's all done now. You should be able to print from your RasPi.

Google Cloud Print

One other interesting thing you might want to do, is to connect the printer with Google Cloud Print. All you need to have is a Google Account and access to the Cloud Print server via Chrome. You DON'T NEED TO install Chrome or Chromium on your Raspberry Pi, once you add the printer on any other machine, you will be able to add it to the service. For a complete guide, head here: Raspberry Pi as Google Cloud Print Connector.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket