Raspberry Pi wireless print server

By the end of this ‘how-to’, you’ll be printing from your computer(s) (Mac, Linux, and Windows) and/or your iPhone. Even if you have a “traditional” printer. Your Raspberry Pi will make you look good…

As I noted in my last post on the subject, I got an RPi the other day with the initial intent on making it a print server to spit out paper at will from the various devices within this house. Behold the glory of wireless printing once again!

With the current set up of my house, I couldn’t have my unsightly Canon MX850 behemoth all-in-one printer in my living room with my router. Thus the family and I would have to trudge all the way upstairs to, dare I say, plug our laptops into the printer to print. Yes, even now in the year 2017 people do still do such mundane tasks. I say people as in people not in this house, because by-golly, I have a working print server allowing me to print from my MacBook, Linux laptop, and all seven of our iDevices (Kindles have not been tested as I write this). I’ll be adding Google Print services at a later date.

What you’ll need:

  • One working Raspberry Pi 3 or Zero with wifi/ethernet (’cause that’s what I have (with Raspbian), and it worked) with VNC turned on or something like TeamViewer installed (that’s what I did)
  • Printer with USB
  • About an hour of time (or if you’re the busy family type… several hours to deal with normal family issues)

Let’s get to work.

Note: There is a lot of Unix/Linux speak/code/crap within here. Don’t worry, you’re more than welcome to copy/paste the code if you prefer. I’ve been dabbling in the Linux realm for the better part of three years and I still don’t have it down myself. Nonetheless, the following steps do work. Also, I used this guide from GeekOnThePC.com (which claims 20 minutes to do this… obviously not one who’s interrupted often) to work much of this out. Kudos to Alex Ward on the great write-up.

One.

I’m running a headless Pi, that is, I have no monitor, mouse, or keyboard connected. It’s just my powered Pi with the printer plugged into it via USB (as pictured above).

If you’ve got yours set up like a “normal” desktop then move on down to step two. Otherwise, let’s get ssh-ing.

Open up terminal (that’s what I’m using on my Mac; use PuTTY for Windows or use Secure Shell on your Chromebook (it works great!)) and at the prompt we’re going to login to our Pi via the SSH protocol. Easy-peasy, however, you need to know the IP address to your Pi. There are lots of ways to find that. For me, it was as easy as opening AirPort Utility on my Mac and hovering over my 8raspberrypi.local8 label. Use your Google powers to find yours.

From here the magic starts. With your IP address in hand, and assuming you haven’t changed any setting (such as login name/password) on your Pi (if you have, you really don’t need to be reading this) let’s SSH into our big-little machine. Type

ssh [email protected] (where xxx.xxx.x.xxx is your IP)

You’ll be asked for your password. Again, assuming you haven’t changed it, your password will be raspberry. I do recommend changing it once you’ve got your server up and running.

Once you’ve gotten logged in you should have a dollar sign ($) for your prompt such as the screen shot above. Now that we’re logged in, let’s get into the fun.

Two.

Now that we’re logged-in: Update. Update. Update. If you’re like me with a brand-new Pi on your hands this is a must. However, even after this, it’s always a good idea to keep your little circuit board updated. Especially when installing new packages. Type

sudo apt-get update

Let that run. This is updating your system packages. If it’s the first time it’ll take about six to ten minutes. Once that’s done then type

sudo apt-get upgrade

This will take a bit as well. What this is doing is updating already installed packages to their most up-to-date versions. If may ask you if you want to upgrade along the way- hitting Y (yes) will get you where you need to be.

Once this is done go ahead and plug your powered printer into the Pi via its USB cable. Once plugged in type

sudo shutdown -r now

You’ll lose your SSH connection. This command is telling your system to reboot, now! The -r is the reboot option for the shutdown command and now does exactly that, it’ll reboot NOW! You can type

man shutdown

to learn more on the shutdown command.

Three.

After the system reboots you can go ahead and reestablish your SSH session as you did in step one. Once connected let’s check if your printer (which should be powered on) is being sensed (it’s magic man!) via the list USB command. Type

lsusb

You should see your printer listed. It’ll look something like this:

[email protected]:~ $ lsusb
Bus 001 Device 004: ID 04a9:172c Canon, Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Well look at that- the ‘ol Canon is listed. Thus far, we’re good to go.

Four.

Time to install our print software/packages for the network printing. Type

sudo apt-get install samba

That’ll install another hefty group of packages; it’s installing the Samba Print Server. If you’re asked if you want to install, type in yes. Otherwise, I guess you could type no, but if you do that you may as well not continue. Installed? Good. Now we’re going to install the Common Unix Printing System, better known as CUPS; type

sudo apt-get install cups

It’ll be another barrage of software. Just let it finish. Once you’re back to your $ prompt we need to install administrator printing privileges so CUPS can manage your printer(s). Type

sudo usermod -a -G lpadmin pi

Five.

Now we’re about to see the payoff of your command-line-fu. But we’re not using the command line for this.


We’re going to view our CUPS admin page. If you have your Pi plugged into a monitor then you can use that setup. If you don’t you can start a VNC session or use TeamViewer to remote in (Google this). Open up your browser on the Pi either physically or via your remote connecting, and go to 127.0.0.1:631, this should give you your CUPS page like this one above.

Here’s Alex Ward’s writeup on this part, he says well…

Click the Administration tab, then click Add Printer. You may be asked to switch to SSL at this point — just follow the link it tells you to go to. You’ll then be prompted to log in — just use your normal Pi credentials (username is usually Pi and the password either raspberry or whatever you might have changed it to.

Once you’re logged in, you should be given a list of currently connected printers. Find yours in the list — it should show up however it is connected (either by USB or over your network). Select it, then click Continue.

At the next step, give it a name (you can keep the default if you wish), a description (this is how your printer will be identified to your iDevice) and a location (optional). Make sure you tick Share This Printer and then click Continue.

Next, you need to select a driver. With any luck your Pi should have already identified a suitable driver — if not, you may need to scroll through the list until you find a suitable candidate. Then click Add Printer and select any default preferences you may have. Click Set Default Options when you’re done and that’s the hardest bit done!

You can check the printer has been added successfully by heading over to the Printers tab and ensuring your printer is shown. To print a test page, select your printer from the list, click the Maintenance dropdown and then click Print Test Page.

Thank you, Mr. Ward.

Six.

You nearly have your own wireless Print Server. Congrats! We’re almost done. While on the CUPS page click the Administration tab; on the right-hand side you’ll see some checkboxes. Within the set of boxes, you’ll want to check the ‘Share printers connected to this system’ and the ‘Allow remote administration’. This first option will allow all of your computers to use the Print Server. The second option will let you remote into the CUPS page via any computer on the same network as your Raspberry Pi.

Click the Change Settings button below the checkboxes. The server will reboot and you NOW you have a Print Server. Just a few more steps…

After you’ve rebooted you’ll be able to get to your CUPS page from a remote computer using your Pi address appended with :631 (xxx.xxx.x.xxx:631).

Seven. (Last steps!)

We need to add support if your Raspberry Pi connected via Wi-Fi and if your computers are devices other than Linux and Apple Laptops/Desktops (but if you’re only running Linux in your realm… you’re done.).

  • Raspberry Pi on WiFi (go ahead and skip if your Pi is connected via ethernet): This command will prevent your wifi from falling asleep as it sits there waiting for you to print something. Type

sudo nano /etc/modprobe.d/8192cu.conf

This will open up the built-in editor. Don’t worry I got your back. With this open copy and paste these two lines into the screen:

# No power saving
options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1

The first line is just a comment to remind you later what the next line actually does. The second it the actual command. You should now see this:


Paste in the code then WriteOut (control+o) and Exit (control+x) if need-be. No sleepy-sleepy for your wifi now.

  • iDevices support (yes, your phones and iPads): Here we’re going to install Bonjour for AirPrint. Via your terminal session type sudo apt-get install avahi-discover

This’ll be a short install but an awesome one. You’ll be able to print from you iPhone and iPads!

  • Windows support: Lastly, if you’ve got a Windows machine you need to print from on your new Print Server, you’ll need to add the following. Again, I’m going to refer to Alex Ward’s work (linked above) as I didn’t install this on my machine (no working Windows machines in this house).

If you want to use your printer with a Windows device after this setup, you’ll need to activate Samba for Windows. To do this, run Terminal once more and run sudo nano /etc/samba/smb.conf

Scroll right to the bottom and then paste in the following:

CUPS printing. See also the cupsaddsmb(8) manpage in the cupsys-client package.
printing = cups
printcap name = cups
[printers] comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = yes
read only = yes
create mask = 0700

# Windows clients look for this share name as a source of downloadable printer drivers

[print$] comment = Printer Drivers
path = /usr/share/cups/drivers
browseable = yes
read only = yes
guest ok = no

Now, do CTRL + W and type in workgroup, followed by Enter to find workgroup configuration. Your workgroup is probably already correctly set it if you haven’t ever changed your workgroup before — if you have, set the correct name at workgroup =. Then change wins support = no to wins support = yes.

Then do CTTL + O on your keyboard, followed by Enter, to save that configuration.

Restart samba with the following command: sudo /etc/init.d/samba restart

Your printer will now work on a Windows network.

You are now done. If all has worked out well you should be able to see the newly installed printer on your new Print Server via your network. Here’s mine on my iPhone:
If you have any questions please don’t hesitate to ask. I’m new with the Pi and love learning and sharing what I’ve learned.

Be First to Comment

Leave a Reply