In an office with multiple users who have individual computers, buying each one of them a printer is inefficient, costly, and unnecessary. Shared printers make more sense. One way to share printers within the network is by setting up a CUPS (Common Unix Printing System) print server.
CUPS is the default print system on Linux and macOS. Once you have installed and configured CUPS on your server, it broadcasts to the network the available printers. The client computers can then add these shared printers to their systems.
So, if you have decent enough hardware to spare, this tutorial will show you how to install a Linux CUPS server and share and connect to the printers using another machine on the network.
- An Ubuntu machine where CUPS will be installed. This post will use an Ubuntu Server 22.04 as the Linux print server.
- A printer to share within the network connected to the CUPS server.
- One or more computers that are connected to the same network. This post will demonstrate adding a shared printer to a Linux and Windows PC.
Step 1: Install CUPS on Ubuntu
The first step is to install the CUPS package on your server. It is possible that CUPS may already be installed on your server out of the box. But it would be best if we install the latest version.
Establish a terminal session on your Linux print server. You can do so by remote SSH login.
Or by opening a terminal window if the server has a desktop environment.
Next, update the local package cache.
sudo apt update
Once updated, run the below command to install CUPS.
sudo apt install cups
Press Enter / Return to continue.
After the installation, confirm that the cups service is enabled and running.
sudo systemctl status cups
The screenshot below shows that the cups service is running and enabled.
Otherwise, run the below commands to start the cups service.
# Start CUPS sudo systemctl start cups # Enable CUPS automatic start sudo systemctl enable cups
Step 2: Configure CUPS
The Linux CUPS server configuration file can be found at /etc/cups/cupsd.conf. In this step, we’ll modify several Linux CUPS server settings. To start, open the configuration file in the text editor.
sudo nano /etc/cups/cupsd.conf
And you should see the contents of the cupsd.conf file, as shown below.
The default Linux CUPS server installation listens only to the loopback interface via port 631 (localhost:631).
To allow other computers on the network to connect, look for the following line:
And replace it with this line. This change means that CUPS will listen on all interfaces via port 631.
Lastly, locate the following lines:
Change the Browsing No to Browsing Yes to enable showing shared printers.
Web Interface Settings
CUPS has a web-based management UI that you can access locally via https://localhost:631. Refer to the image below showing the CUPS web interface.
But at this point, you can only access this link on the local computer. If you try to access the CUPS web page remotely, you’ll get the Forbidden error, as shown below.
To make the web interface accessible within the network, look for the following lines.
# Restrict access to the server... <Location /> Order allow,deny </Location> # Restrict access to the admin pages... <Location /admin> Order allow,deny </Location>
Insert the line Allow @LOCAL at the end of each location tag.
# Restrict access to the server... <Location /> Order allow,deny Allow @LOCAL </Location> # Restrict access to the admin pages... <Location /admin> Order allow,deny Allow @LOCAL </Location>
The file will now look like the screenshot below. Save the file and exit the text editor.
For the changes to take effect, let’s restart cups.
sudo systemctl restart cups
Lastly, add your user account to the lpadmin group.
Note. Only the lpadmin group members can manage the Linux CUPS server via the web interface.
# Add your user account to lpadmin group sudo usermod -aG lpadmin $USER # Refresh the group membership newgrp lpadmin # Confirm that your account is now a member groups $USER
Now, try to access the CUPS web UI remotely, which should now load.
Note. If you notice, accessing the CUPS web UI does not ask for a password. You’ll be asked to authenticate only when you make changes, like adding new printers. All of these can be customized in the cupsd.conf file.
Step 3: Install CUPS Printer Drivers
The CUPS server Linux installation comes pre-installed with the HP Linux Imaging and Printing (HPLIP) drivers and the [printer-driver-gutenprint] (https://packages.ubuntu.com/jammy/printer-driver-gutenprint) package, which contains drivers for other printers, like Canon, Epson, etc.
But, if these printer drivers are not present, run the below command to install them.
sudo apt install -y printer-driver-gutenprint hplip
If you have a printer that isn’t included in the default CUPS printer drivers, you can search for the driver from https://openprinting.org/.
For example, the printer EPSON L110 is not available by default. In this case, you can locate and download the driver package.
Your Linux CUPS server is running, and now it’s time to add a printer to share.
On the CUPS web UI, click Administration → Add Printer.
And since you’re making a configuration change, you must authenticate using your credentials.
Now you can see several options. You can select locally attached printers, discovered network printers, and manually enter other network printers.
In this example, I’d like to share an EPSON L110 printer attached to the server. Select the printer and click continue.
Specify the Name, Description, and Location. Also, check the Share This Printer checkbox, and click Continue.
Next, select the appropriate driver for the printer, and click Add printer.
And you’ve successfully shared the printer.
Step 5: Add Printer on the Client Computer
Linux or macOS Clients
Most Linux distributions and macOS already have support for CUPS printers, which means that they can automatically detect CUPS-shared printers on the network.
For example, on Ubuntu, open Settings → Printers and click Add Printer.
Ubuntu starts searching for printers.
Select the detected printer, in this case, the L110 server, and click Add.
The printer is now added to the Ubuntu PC.
Once added, you can see that the printer is now ready.
You can also see the printer in the Devices and Printers control panel.
You’ve learned in this post how to install and configure a Linux CUPS server in Ubuntu. What you’ve learned in this post barely scratches the surface. There are many more configurations and customization you can do with CUPS.
CUPS does not only provide unified printing for Linux and macOS, but it is also a Linux print server for Windows clients.
Aside from sharing printers attached locally to the server, you can also share and advertise other network printers. But it’s up to you to try it!