How to Install CUPS on Ubuntu Server 20.04

Post Reply
User avatar
LHammonds
Site Admin
Site Admin
Posts: 982
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

How to Install CUPS on Ubuntu Server 20.04

Post: # 995Post LHammonds »

------------- WORK-IN-PROGRESS -------------

Greetings and salutations,

I hope this thread will be helpful to those who follow in my foot steps as well as getting any advice based on what I have done / documented.

To discuss this thread, please participate here: Ubuntu Forums

High-level overview

This document will describe how to setup a CUPS print server. This will not be a restricted nor limited configuration. Credentials will not be needed to use the printers but they will be required to utilize administrative functions in the web interface.

Tools utilized in this process
Helpful links

The list below are sources of information that helped me configure this system.
Assumptions

This documentation will need to make use of some very-specific information that will most-likely be different for each person / location. This variable data will be noted in this section and highlighted in red throughout the document as a reminder that you should plug-in your own value rather than actually using these "place-holder" values.

Under no circumstance should you use the actual values listed below. They are place-holders for the real thing. This is just a checklist template you need to have answered before you start the install process.

Wherever you see RED in this document, you need to substitute it for what your company uses.
  • Printer Admin Credentials: User = printadmin, password = print123
  • Unknown: Unknown
User avatar
LHammonds
Site Admin
Site Admin
Posts: 982
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Install Ubuntu Server

Post: # 996Post LHammonds »

Install Ubuntu Server

The 1st thing to do is the installation of Ubuntu Server. The following guide will describe how to setup a server for use in a production environment and this document assumes the guide was followed to setup Ubuntu.

The server install guide also contains an "Assumption" section with variables colored in RED, instead of using those values, this guide will instead use the following as replacements:

Ubuntu Server name: srv-print
Ubuntu Server IP address: 192.168.107.45

IMPORTANT: Keep in mind, these are typically different for each site/install. Do not use these exact values yourself...make up your own that matches your environment, write them down and use them instead of the values in the guide.

NOTE: These are the sections you can skip in the server install guide which are not necessary for this server (however, you might want them...it is up to you):
  • Configure Ubuntu for File Sharing (Samba)
  • Configure Windows Server as a Remote Mount Point
  • SSH Public and Private Keys
Follow the How to Install Ubuntu Server guide and come back when finished.
User avatar
LHammonds
Site Admin
Site Admin
Posts: 982
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Install CUPS

Post: # 997Post LHammonds »

Firewall Rules

Edit the firewall script that was created during the initial setup of the server (if you followed my instructions):

Code: Select all

sudo vi /var/scripts/prod/en-firewall.sh
Add (or enable) the following:

Code: Select all

echo "Adding CUPS Server rules"
ufw allow proto tcp to any port 631 comment 'Web Print Admin' 1>/dev/null 2>&1
ufw allow proto udp to any port 5353 comment 'Print' 1>/dev/null 2>&1
Run the updated rules:

Code: Select all

sudo /var/scripts/prod/en-firewall.sh
Install CUPS Service

Code: Select all

sudo apt -y install cups
Once installation is finished, verify that it is running using the command below and look for "active (running)"

Code: Select all

systemctl status cups
Create Printer Admin User

When you need to access administrative areas on the CUPS web interface, you will need to supply the credentials for this user (such as adding / deleting printers)

These commands will create the user, add it to the printer admin group and set the password to whatever you want.

Code: Select all

sudo useradd --comment "Printer Admin" --shell /bin/bash --no-user-group printadmin
sudo usermod -aG lpadmin printadmin
sudo passwd printadmin
Configure CUPS

Since we are running CUPS on a headless server (with no GUI), we cannot access the web interface because it is only accessible via the localhost by default. We need to modify the configuration to allow access from another machine. Backup the configuration file before editing it.

Code: Select all

sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.bak
sudo vi /etc/cups/cupsd.conf
Change:

Code: Select all

?
to

Code: Select all

Port 631
Change:

Code: Select all

Browsing Off
BrowseLocalProtocols dnsd
to

Code: Select all

Browsing On
BrowseLocalProtocols dnssd
Change:

Code: Select all

<Location />
  # Allow remote access...
  Order allow,deny
</Location>
<Location /admin>
  Order allow,deny
</Location>
to

Code: Select all

<Location />
  # Allow remote access...
  Order allow,deny
  Allow all
</Location>
<Location /admin>
  Order allow,deny
  Allow all
</Location>
Restart CUPS for the changes to take effect:

Code: Select all

sudo systemctl restart cups
User avatar
LHammonds
Site Admin
Site Admin
Posts: 982
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Add Additional Print Drivers

Post: # 998Post LHammonds »

Add Additional Print Drivers

PPD files are placed here: /usr/share/ppd/

Example for installing Brother and HP drivers included in the Ubuntu repository:

Code: Select all

sudo apt -y install brother-cups-wrapper-common
sudo apt -y install brother-cups-wrapper-extra
sudo apt -y install brother-cups-wrapper-laser
sudo apt -y install brother-cups-wrapper-laser1
sudo apt -y install hplip
You can also download specific PPD files from this site: https://www.openprinting.org/download/PPD/

Examples for specific / individual Kyocera printers:

Code: Select all

mkdir /tmp/Kyocera
cd /tmp/Kyocera
wget https://www.openprinting.org/download/oldPPDs/Kyocera/current/English/Kyocera_FS-1000_English.ppd
wget https://www.openprinting.org/download/oldPPDs/Kyocera/current/English/Kyocera_FS-5900C_English.ppd
wget https://www.openprinting.org/download/oldPPDs/Kyocera/current/English/Kyocera_FS-7000_English.ppd
wget https://www.openprinting.org/download/oldPPDs/Kyocera/current/English/Kyocera_Mita_KM-4030_English.ppd
sudo mkdir /usr/share/ppd/Kyocera
sudo mv /tmp/Kyocera/* /usr/share/ppd/Kyocera/.
cd /tmp
rm -rf /tmp/Kyocera
Example for Kyocera package of many printers:

Code: Select all

cd /tmp
wget https://www.openprinting.org/download/printdriver/debian/dists/lsb3.2/main/binary-amd64/openprinting-ppds-postscript-kyocera_20160218-1lsb3.2_all.deb --output-document /tmp/print.deb
mkdir /tmp/print
dpkg-deb -xv print.deb /tmp/print
cd /tmp/print/opt/OpenPrinting-Kyocera/ppds/Kyocera
gunzip *.gz
sudo mkdir /usr/share/ppd/Kyocera
sudo mv /tmp/print/opt/OpenPrinting-Kyocera/ppds/Kyocera/*.ppd /usr/share/ppd/Kyocera/.
cd /tmp
rm /tmp/print.deb
rm -rf /tmp/print
Example for Ricoh package of many printers:

Code: Select all

cd /tmp
wget https://www.openprinting.org/download/printdriver/debian/dists/lsb3.2/main/binary-amd64/openprinting-ppds-postscript-ricoh_20161206-1lsb3.2_all.deb --output-document /tmp/print.deb
mkdir /tmp/print
dpkg-deb -xv print.deb /tmp/print
cd /tmp/print/opt/OpenPrinting-Ricoh/ppds/Ricoh
gunzip *.gz
sudo mkdir /usr/share/ppd/Ricoh
sudo mv /tmp/print/opt/OpenPrinting-Ricoh/ppds/Ricoh/*.ppd /usr/share/ppd/Ricoh/.
cd /tmp
rm /tmp/print.deb
rm -rf /tmp/print
Example for Xerox package of many printers:

Code: Select all

cd /tmp
wget https://www.openprinting.org/download/printdriver/debian/dists/lsb3.2/main-nonfree/binary-amd64/openprinting-ppds-postscript-xerox_20130226-1lsb3.2_all.deb --output-document /tmp/print.deb
mkdir /tmp/print
dpkg-deb -xv print.deb /tmp/print
cd /tmp/print/opt/OpenPrinting-Xerox/ppds/Xerox
gunzip *.gz
sudo mkdir /usr/share/ppd/Xerox
sudo mv /tmp/print/opt/OpenPrinting-Xerox/ppds/Xerox/*.ppd /usr/share/ppd/Xerox/.
cd /tmp
rm /tmp/print.deb
rm -rf /tmp/print
Example for Lexmark package of many printers:

Code: Select all

cd /tmp
wget https://www.openprinting.org/download/printdriver/debian/dists/lsb3.2/main/binary-amd64/openprinting-ppds-postscript-lexmark_20160218-1lsb3.2_all.deb --output-document /tmp/print.deb
mkdir /tmp/print
dpkg-deb -xv print.deb /tmp/print
cd /tmp/print/opt/OpenPrinting-Lexmark/ppds/Lexmark
gunzip *.gz
sudo mkdir /usr/share/ppd/Lexmark
sudo mv /tmp/print/opt/OpenPrinting-Lexmark/ppds/Lexmark/*.ppd /usr/share/ppd/Lexmark/.
cd /tmp
rm /tmp/print.deb
rm -rf /tmp/print
Example for Epson package of many printers:

Code: Select all

cd /tmp
wget https://www.openprinting.org/download/printdriver/debian/dists/lsb3.2/main/binary-amd64/openprinting-ppds-postscript-epson_20130226-1lsb3.2_all.deb --output-document /tmp/print.deb
mkdir /tmp/print
dpkg-deb -xv print.deb /tmp/print
cd /tmp/print/opt/OpenPrinting-Epson/ppds/Epson
gunzip *.gz
sudo mkdir /usr/share/ppd/Epson
sudo mv /tmp/print/opt/OpenPrinting-Epson/ppds/Epson/*.ppd /usr/share/ppd/Epson/.
cd /tmp
rm /tmp/print.deb
rm -rf /tmp/print
Example for Samsung package of many printers:

Code: Select all

cd /tmp
wget https://www.openprinting.org/download/printdriver/debian/dists/lsb3.2/main/binary-amd64/openprinting-ppds-postscript-samsung_20160401-1lsb3.2_all.deb --output-document /tmp/print.deb
mkdir /tmp/print
dpkg-deb -xv print.deb /tmp/print
cd /tmp/print/opt/OpenPrinting-Samsung/ppds/Samsung
gunzip *.gz
sudo mkdir /usr/share/ppd/Samsung
sudo mv /tmp/print/opt/OpenPrinting-Samsung/ppds/Samsung/*.ppd /usr/share/ppd/Samsung/.
cd /tmp
rm /tmp/print.deb
rm -rf /tmp/print
Make sure all PPD files have the correct ownership and permissions configured:

Code: Select all

sudo chown --recursive root:root /usr/share/ppd/*
sudo find /usr/share/ppd/ -type d -print0 | sudo xargs -0 chmod 0755
sudo find /usr/share/ppd/ -type f -print0 | sudo xargs -0 chmod 0644
After PPD files are in place, you will need to restart the CUPS service for it to see the new files:

Code: Select all

sudo systemctl restart cups
User avatar
LHammonds
Site Admin
Site Admin
Posts: 982
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Printer Management

Post: # 999Post LHammonds »

Add New Printer to CUPS

These steps will demonstrate how to add a Brother HL-5150DN printer that is already connected to the network via a network cable and has a valid static IP assigned.
  1. Access the CUPS admin site - http://192.168.107.45:631/ (substitute the IP address of your CUPS server)
  2. Select the Administration tab
  3. Click
    Add Printer
    button
  4. Select AppSocket/HP JetDirect and click
    Continue
  5. Set Connection to socket://192.168.107.120 (substitute 192.168.107.120 for the IP of your printer) and click
    Continue
  6. Set the following options to your liking and click
    Continue
    :
    Name: Brother5150DN
    Description: Dr. Goldfinger Receptionist
    Location: Building 1-A, Room 2
    Checked: Share This Printer
  7. Select the make of the printer and click
    Continue
    :
    Example: Brother
  8. Select the Model of the printer and click
    Add Printer
    :
    Example: Brother HL-5150DN for CUPS
  9. Set the default options as desired (if any) and click
    Set Default Options
Print Test Page from CUPS
  1. Access the CUPS admin site - http://192.168.107.45:631/ (substitute the IP address of your CUPS server)
  2. Select the Printers tab
  3. Click the printer (Example: Brother HL5150DN)
  4. On the Maintenance drop-down selection, select "Print Test Page" and CUPS will immediately send a print job to that printer.
  5. If the test page did not print, click the Jobs tab and see what the error message says. If it shows "The printer is not responding" then you need to verify you used the correct IP address and that the IP is accessible from the CUPS server.
Connect Windows to a CUPS Printer

These steps will demonstrate connecting a recently-created printer in CUPS to a Windows 10 client.
  1. In Windows, click the search bar and type/find "Printers & Scanners"
  2. Once the window is open, click "Add a printer or scanner"
  3. It should show a list of printers configured on the CUPS server. Select the Printer you just created and click
    Add device
  4. Windows will add the printer and make it available as a printer output device
Print Test Page from Windows
  1. In Windows, click the search bar and type/find "Printers & Scanners"
  2. Once the window is open, select the printer you just added and click
    Manage
  3. On the "Manage your device" window, click "Print a test page"
  4. If the test page did not print, click the Jobs tab on the CUPS admin site and see what the error message says. If it shows "The printer is not responding" then you need to verify you used the correct IP address and that the IP is accessible from the CUPS server.
Connect Ubuntu Desktop to a CUPS Printer

These steps will demonstrate connecting a recently-created printer in CUPS to an Ubuntu 20.04 desktop client.

>> NEED TO VERIFY / REFINE THE BELOW STEPS <<
  1. Login to Ubuntu Desktop
  2. Click on Settings, Printers, Add
  3. Select the recently-added printer
Post Reply