How to Set up a Print Server on Linux
After years of working as a support technician, I can tell you one of the most frustrating pieces of technology out there is the printer. When they work, they are an indispensable tool in the office. When they don’t work (as it often happens), they are a never-ending point of frustration.
This is especially true when your printer is attached to a Windows machine that can cause any number of problems, without rhyme or reason. Getting that shared printer back up and running can take some time. Or you might wind up having to call in support.
To make matters worse, printer problems don’t just plague end users. This almost universal bone of contention causes problems for every level of the user, even all the way up to JavaScript developers, like those at BairesDev.
Fortunately, there’s a way for your business to avoid the headaches brought about by sharing printers from desktop machines. That solution is to deploy a Linux printer server. Once you have such a server up and running, you’ll find it will serve you without fail (so long as the hardware and your network don’t become a problem).
Outside of reliability, the fact that you’ll be using open source means the only cost for you is the hardware.
Requirements
First off, you need to have a printer that supports Linux. At one point in time, this was a challenge that caused many users to avoid the Linux print server. But that’s all in the past. Today, it’s fairly easy to have a Linux printer. To find out what printers are supported by Linux, check out the OpenPrinting site.
With your supported printer at the ready, you’ll need to make sure it’s connected to your Linux server.
You’ll also need to have a Linux server available. I’ll be demonstrating with Ubuntu Server 18.04, as that’s one of the most user-friendly Linux server distributions on the market. Do note, however, that Ubuntu Server 18.04 installs without a GUI, so you’ll be working from the command line.
Finally, you’ll need a user with sudo privileges.
And that it’s. Let’s get to work.
Installing the CUPS printer server software
The first thing to take care of is the installation of the CUPS printer server software. CUPS stands for Common Unix Printer Server and has been around for some time.
To install CUPS, log into your Ubuntu server and issue the command:
sudo apt-get install cups -y
Once the installation completes, you’ll need to start the CUPS daemon and configure it to start at boot (otherwise you’ll have to start it manually anytime the server goes down). To start the CUPS daemon, issue the command:
sudo systemctl start cups
To enable the CUPS daemon at boot, issue the command:
sudo systemctl enable cups
Configuring CUPS
With CUPS installed, it’s time to configure it. Only a few quick changes need to be made within the configuration file. To open that file for editing, issue the command:
sudo nano /etc/cups/cupsd.conf
The first change you need to make is the line:
Browsing Off
Change that to:
Browsing On
Next, you need to configure CUPS so that the web-based manager is accessible from within your Local Area Network (LAN). Look for the line:
Listen localhost:631
Change that line to:
Port 631
For our next trick, you’ll have to make sure that CUPS is listening on all network interfaces. Look for the following section:
<Location />
Order allow, deny
</Location>
Change that to:
<Location />
Order allow, deny
Allow @LOCAL
</Location>
Finally, you’ll want to add access to the CUPS web-based admin console. Look for the section:
<Location /admin>
Order allow, deny
</Location>
Change that to:
<Location /admin>
AuthType Default
Require valid-user
Order allow, deny
Allow @LOCAL
</Location>
If you do opt to make the web-based admin console available, you might want to lock it down to allow only a specific user. To do this, you would change the line:
Require valid-user
to
Require user @SYSTEM
Save and close the cupsd.conf file. Restart the CUPS daemon with the command:
sudo systemctl restart cups
If you opted to lock down the admin console to a specific user, you’ll want to create that user with the command:
sudo useradd -g lpadmin cupsadmin
Set the new user’s password with the command:
sudo passwd cupsadmin
With that configuration, you can point a browser to https://SERVERIP/admin (where SERVERIP is the IP address of the machine hosting CUPS). You will be prompted to log in with the cupsadmin user and the password you set above.
Share the printer via Bonjour and IPP protocols
You’ll want to make sure your printer is visible to your LAN via Bonjour (for macOS desktops) and IPP (for most other desktops). To make this work, you’ll need to install the avahi daemon with the command:
sudo apt install avahi-daemon -y
Once installed, start and enable the daemon with the commands:
sudo systemctl start avahi-daemon
sudo systemctl enable avahi-daemon
Open the firewall
If you happen to have the UFW firewall enabled on the Server, allow Bonjour and IPP printer traffic through with the command:
sudo ufw all 5353/udp
Connecting your printer
At this point, everything is ready for desktops to connect. How you connect the desktop to the printer server will depend on which desktop you are using. For example, with Pop!_OS Linux, I can go to Settings > Printers, and (as long as the necessary drivers are installed) the new printer will automatically appear (Figure 1).
Figure 1
Our printer on the CUPS printer server is now available for connection.
Conclusion
And that’s all there is to set up a reliable Linux printer server. The only hiccup you will run across is if you have entities outside of your LAN (such as third-party JavaScript development companies). To allow those groups to use the printers connected to the server, you’ll need to employ a VPN. Otherwise, your printer server is ready and should serve you without fail.