How to Set Up a CUPS Print Server on Linux?

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.

Requirements

  • 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.

ADVERTISEMENT

Establish a terminal session on your Linux print server. You can do so by remote SSH login.

cups print server

Or by opening a terminal window if the server has a desktop environment.

cups linux

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.

cups server

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.

linux print server

ADVERTISEMENT

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.

ubuntu cups

Connections Settings

The default Linux CUPS server installation listens only to the loopback interface via port 631 (localhost:631).

Port 631 is the well-known port for the Internet Printing Protocol (IPP).

To allow other computers on the network to connect, look for the following line:

Listen localhost:631

linux cups printing

ADVERTISEMENT

And replace it with this line. This change means that CUPS will listen on all interfaces via port 631.

Port 631

set up cups print server

Lastly, locate the following lines:

Browsing No

install cups ubuntu

Change the Browsing No to Browsing Yes to enable showing shared printers.

Browsing Yes

install cups linux

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.

linux cup

ADVERTISEMENT

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.

cups configuration in linux step by step

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.

linux cups server

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

linux cups service

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.

cups ubuntu server

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.

cups server ubuntu

Step 4: Share a Printer

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.

cups airprint server

And since you’re making a configuration change, you must authenticate using your credentials.

cups server linux

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.

install cups server

Specify the Name, Description, and Location. Also, check the Share This Printer checkbox, and click Continue.

cups printing service

Next, select the appropriate driver for the printer, and click Add printer.

linux print server cups

And you’ve successfully shared the printer.

cups print server on linux

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.

cups server on linux

Ubuntu starts searching for printers.

add printer cups server

Select the detected printer, in this case, the L110 server, and click Add.

cups linux printer

The printer is now added to the Ubuntu PC.

cups setup

Windows Client

cups setup linux windows

Once added, you can see that the printer is now ready.

cups setup linux windows print server

You can also see the printer in the Devices and Printers control panel.

cups linux printer devices

Conclusion

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!

I enjoy technology and developing websites. Since 2012 I'm running a few of my own websites, and share useful content on gadgets, PC administration and website promotion.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.