How to Setup a Print Server on Linux Ubuntu 20.04 (CUPS)

How to Setup a Print Server on Linux Ubuntu 20.04 (CUPS). CUPS (Common UNIX Printing System) is the official cloud printing system for Unix-like operating systems.

It is primarily used to install and configure printers on a computer. It also allows you to submit jobs and receive results through a network client or local printing device.

CUPS is used in all Linux distributions, as well as most other UNIX like operating systems (such as Solaris and FreeBSD).

This article will show you how to set up a print server on Linux Ubuntu 20.04 with CUPS.

What is CUPS

CUPS is the acronym for Common Unix Printing System. It is a software printing system for Unix like operating systems and their counterparts, including Linux, OpenBSD, and Solaris.

CUPS is a suite of programs that together provide a flexible, scalable printing system. It provides an easy to use, user friendly interface for creating and managing printers and has several different print functions, including server and client based printing.

The CUPS print server has been designed to be a robust, scalable and secure printing system that can be used with a wide range of printers, including networked printers and those connected directly to the hardware (LPD).

CUPS was developed by Apple Inc. and support for CUPS in Linux has been growing steadily since version 1.1 in 1995. The latest stable release is 2.3.9 which supports a wide range of printers, including USB printers and networked printers.

Besides Linux, CUPS is also available on all major platforms, including Microsoft Windows, macOS, and Android.

The Advantages of CUPS

 The advantages of CUPS are:

  • CUPS is maintained by an open community of developers who continually improve and enhance it.
  • It supports several printing backends: LPD/LPRng, Level Printer Spooler (LPR), and GPX.
  • It is easy to use and configure.
  • You can print a lot of different types of documents and images.
  • CUPS supports both local and remote printing.
  • It is compatible with most printers and scanners, including laser printers, inkjet printers, plotters, etc. 
  • It lets you manage all your print jobs easily from one place without having to visit each job folder separately. 

Follow this post to learn how to Setup a Print Server on Linux Ubuntu 20.04 (CUPS).

How to Setup a Print Server on Linux Ubuntu 20.04 (CUPS)

Prerequisites

  • A network connection to the printer on a system running Ubuntu server 20.04
  • To access the printer, you will need a client version of Ubuntu or a server version.

Install CUPS Print Server on Ubuntu

Update your system to ensure all packages are updated.

				
					sudo apt update
				
			

The Ubuntu Desktop edition is pre-installed with CUPS. Run the following command in your terminal to install CUPS on the Ubuntu server edition.

				
					sudo apt install cups 
				
			

Output:

				
					Reading package lists... Done
Building dependency tree       
Reading state information... Done
cups is already the newest version (2.3.1-9ubuntu1.2).
cups set to manually installed.
…

				
			

Start and Enable CUPS service

Once CUPS is installed on your system, you need to start and enable the cups service on boot. 

Run the following command to start the CUPS print service.

				
					sudo systemctl start cups
				
			

Next, verify that the service is running as intended by checking the service status.

				
					sudo systemctl status cups
				
			

Output:

				
					● cups.service - CUPS Scheduler
     Loaded: loaded (/lib/systemd/system/cups.service; enabled; vendor preset: enable>
     Active: active (running) since Sat 2022-06-18 09:28:45 PDT; 13s left
TriggeredBy: ● cups.path
 …

				
			

You can also enable the CUPS service to run on boot with the following command.

				
					sudo systemctl enable cups
				
			

Output:

				
					Synchronizing state of cups.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable cups

				
			

Setup and Configure the CUPS

You can configure CUPS through the web interface here, or you can do it manually through the /etc/cups/cupsd.conf file using the following steps.

Backup Configuration File

It is recommended to backup configuration files before making changes in case something goes wrong.

You can make a backup copy of the /etc/cups/cupsd.conf file using the following command.

				
					sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.copy
				
			

Open and Edit the Configuration File

Open the /etc/cups/cupsd.conf file in the nano editor using the following command.

				
					sudo nano /etc/cups/cupsd.conf
				
			

First, go to the Only listen for connections from the local machine section in the file and add the following line to specify 631 as the default port.

				
					#Listen localhost:631
Port 631
				
			

Next, go to the Show shared printers on the local network section of the file and enable Browsing On. This will show shared printers on the local network.

				
					Browsing On
				
			

Set BrowseLocalProtocols to dnssd protocol.

				
					BrowseLocalProtocols dnssd
				
			

Now, go to the Restrict access to the server section and add Allow @LOCAL to allow access to other computers on the network.

				
					#Restrict access to the server

 Order allow,deny
Allow @LOCAL

				
			

Similarly, add Allow @LOCAL  under the Restrict access to the admin pages section.

				
					#Restrict access to the admin pages.

Order allow,deny
Allow @LOCAL


				
			

Press Ctrl+O and Ctrl+X to save and exit the file.

Restart the CUPS service for the changes to take effect.

				
					sudo systemctl restart cups
				
			

Add User to lpadmin Group

It is advised to use either root or a user authorized in the lpadmin group if you want to set up via the CUPS web interface.

				
					sudo usermod -aG lpadmin 
				
			

Install Your Printer Driver

On the majority of Linux distributions, printer drivers are already included. Use the following command to install the HP driver, if it is not installed.

				
					sudo apt install hplip
				
			

For printers other than HP printers, you can consult openprinting.org.

Install Bonjour for CUPS Printer Sharing

You have to install the avahi-daemon, which is a Bonjour server that broadcasts information from your machine to the network and supports mDNS/DNS-SD service discovery.

The Bonjour (DNSSD) protocol aids in making printing a network-discoverable service.

You can install avahi-daemon using the following command.

				
					sudo apt install avahi-daemon
				
			

Then, start and enable the avahi-daemon service on boot with the following command.

				
					sudo systemctl start avahi-daemon
sudo systemctl enable avahi-daemon

				
			

Next, verify the avahi-daemon service by checking its status.

				
					sudo systemctl status avahi-daemon
				
			

Output:

				
					● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabl>
     Active: active (running) since Sat 2022-06-18 09:59:44 PDT; 2min 7s ago
TriggeredBy: ● avahi-daemon.socket
...
				
			

Configure Firewall to Unblock Ports

You need to allow ports 631 and 5353 for cups and avahi-daemon respectively.

 

 Run the following commands to unblock them.

				
					sudo ufw allow 631/tcp
sudo ufw allow 5353/udp

				
			

Add a Printer to Your System

Go to Settings > Printers and click on Add. You should see your printer under the Network Printer.

If you do not see it, provide the printer IP to manually add it.

Great job! We have learned how to Setup a Print Server on Linux Ubuntu 20.04 (CUPS).

How to Setup a Print Server on Linux Ubuntu 20.04 (CUPS) Conclusion

In this guide, we have shown you how to set up a CUPS print server on Linux Ubuntu 20.04.

CUPS, or the Common UNIX Printing System, is a printing system for UNIX-like operating systems. It’s an open source software package that aims to provide a standard printing solution.

If you are interested in alternate solutions for printing, explore our content on printing.

Avatar for Sobia Arshad
Sobia Arshad

Information Security professional with 4+ years of experience. I am interested in learning about new technologies and loves working with all kinds of infrastructures.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x