In order to connect a printer with the Raspberry Pi, first we need to install CUPS (Common Unix Printing System). Open a terminal session with the RPi and type:
sudo apt-get install cups
In a few seconds it will ask you if you want to install the software packages and the amount of space will take from your SD card. Hit Y and then enter
The installation process will take a good amount of time as CUPS is a fairly beefy install. Sometimes even close to 15 minutes (depending on your internet connection and the SD card). After the end of installation we have to add the user pi (or any other user we are working on) to the user group created automatically by CUPS. This user group is “lpadmin”. To do that type:
sudo usermod -a -G lpadmin pi
If you are working with another username then you can adjust the previous command accordingly. Instead of “pi” add the username you are working! Simple like that!
Now, its time to enable remote editing of the CUPS configuration file. This will enable us to change working conditions, add printers, modify print jobs etc from any browser window of any PC/Laptop of even mobile device connected to our network. Type:
sudo nano /etc/cups/cupsd.conf
The nano editor will open and inside this configuration file we must edit a few bits and pieces. To begin with find:
# Only listen for connections from the local machine.
and add a # on the beginning of the second line and then add “Port 631” next like I am showing bellow:
# Only listen for connections from the local machine.
# Restrict access to the server…
and add “Allow @local” before the last line. Do exactly the same to the following parts as I am showing here:
# Restrict access to the admin pages…
# Restrict access to configuration files…
Require user @SYSTEM
The result should be like on the next picture. I’ve noted the locations that you have to do the modifications for quick searching.
The addition of the “Allow @local” line gives access to CUPS from any computer on your local network. Feel free to change that according to your needs. For example if you have a set of computers working on a sub network with IP addressing like 10.0.0.* then you can add “Allow 10.0.0.*” instead of “Allow @local”. Or if you want remote editing of CUPS configurations from a specific computer with a static IP then add Allow and the IP of this computer. On top of that, for the Listen part you can use “Listen *:631” and will have the same effect as the one we wrote.
Have a look once more if everything is modified correctly and then press Ctrl-X, Y and finally Enter to accept all the changes and save the file. To work with the current changes we must restart CUPS:
sudo /etc/init.d/cups restart
And we are done! At least from what we have to do from the terminal window. Connect your printer to an available USB port on your RPi (you can use a hub as well). Open a browser window and type the IP address of the Pi together with the :631 on the end. The end number is the port CUPS listens for connections. For example:
Go to the Administration tab (it is the second one on the top of the screen) and then press Add Printer
It will ask you for user name and password. Add the user name and password of the user you are woking for on the Raspberry Pi. For example if you running a default Raspbian distribution then those are pi and raspberry respectively. I strongly recommend to change the password if you are still using the default user pi settings!
Now, CUPS will perform an automatic scan for connected printers on the Raspberry Pi or in the network in general and will present all of those. Select the one you are looking for, a really old Canon S200 in my case, and press continue. Now fill the text boxes with a few more info about the location of the printer, description etc and then again hit Continue
After editing the previous settings, CUPS will ask you to select the recommended driver. Usually the driver will have the exact name of the printer and you have to select this one. Alternatively, if you can’t find the printer driver you can download from the manufacturer the PPD file and use this one or use the general printer driver per brand.
Press Add Printer on the previous screen. For the last configuration step, you have to look over some general print settings like media size, print quality, resolution etc
When you finish, press Set Default Options and you are good to go! You will be presented with the default administration page for the printer you just configure. Now, you can print anything you like from your Raspberry Pi. For any other computer/laptop/mobile device on your network you can follow the normal procedure to add a network printer. It differs from operating system to operating system and thats why I am not writing about it. If you don’t know how to do that then google it. It’s an easy process… don’t worry about it!
AirPrint from any Apple device
With CUPS, except of printing from Raspberry Pi and making a printer seen on anywhere on the network it adds also support for the AirPrint of Apple! To enable this functionality just select something you wan to print from your iPhone, iPod or iPad. Lest say for example a note on the Notes App.
The press the icon on the bottom left of the screen and select Print. On the Printer section choose the printer you already install by following the previous steps and then press Print. Like magic the note you took on your iPhone will get printed on your