Full CUPS Guide: Setting, using and troubleshooting in Linux

Introduction

In the Linux world, printer management may seem a simple task until you need to share devices on a network, set up advanced options or fix printing errors. Here comes the Common Unix Printing System (CUPS), the de facto standard for handling working tails, drivers and printing protocols in virtually all modern distributions. This article will guide you step by step from installation to advanced administration, offering practical examples and tips of troubleshooting so you can keep your printing environment running without interruption.

What is CUPS?

CUPS, acronym of Common Unix Printing System, was initially developed by Apple and released under GPL license. It acts as a printing server that receives printing work from client applications, processes them by filters and sends them to the appropriate printer using protocols such as IPP (Internet Printing Protocol), LPD or SMB. Its modular architecture allows to add new drivers, filters and backends without changing the system's core, making it extremely flexible in both desktop and corporate printing servers.

Installation in main distributions

In most Debian-based distributions, the package is installed with:

  • sudo apt update
  • sudo apt install cups

In systems based on RHEL, Fedora or CentOS, the equivalent command is:

  • sudo dnf install cups(Fedora)
  • sudo yum install cups(RHEL / CentOS)

After installation, the service starts automatically, but you can check and enable it to start with:

  • sudo systemctl status cups
  • sudo systemctl enable --now cups

If you prefer a graphic interface, many desktop environments include tools such assystemor the configuration of GNOME / KDE printers, which simply act as CUPS fronts.

Basic configuration

The main CUPS configuration file is found in/etc/cups/cupsd.conf. Here you can define the listening port (by default 631), the access directives and the level of registration. A typical example to allow access from the local network is:

# Listen at all interfacesOrder allow, deny Allow 192.168.1.0 / 24

After editing the file, restart the service:

  • sudo systemctl restart cups

To add a printer, you can use the web interface (see next section) or commandlpadmin. For example, to add an automatically detected USB printer:

  • sudo lpadmin -p Impresora_USB -E -v usb://HP/Deskjet?serial=ABC123 -m everywhere

The Flag-Eenables the printer and accepts jobs, while-m everywhereindicates that the generic controller recommended by CUPS is used.

Management via web interface

CUPS includes an accessible management interface using a browser in the directionhttp://localhost:631. From there you can:

  • See the state of the printing tails.
  • Add, modify or delete printers.
  • Configure specific options such as resolution, paper type and fold.
  • Review the job register (jobs) and perform actions such as pausing, resuming or cancelling jobs.
  • Manage users and permissions using the tabAdministration.

To access the administration section it is necessary to authenticate with a user belonging to the grouplpadminOr the root account. You can add your user to the group with:

  • sudo usermod -aG lpadmin $USER
  • newgrp lpadmin(or close and relog)

The web interface also allows you to load custom PPD files (PostScript Printer Description), which is useful when you have a specific driver provided by the manufacturer.

Use of the command line

In addition to the graphic interface, CUPS offers a set of CLI tools that are ideal for scripts and remote management. The most used commands are:

  • lpstat -p: lists all the configured printers and their status.
  • lpstat -a: shows printers accepting jobs.
  • lp -d Impresora_USB archivo.pdf: send a job to the specified printer.
  • cancel -a: Cancels all outstanding work.
  • cupsaccept Impresora_USB: allows the printer to accept new jobs.
  • cupsreject Impresora_USB: rejects new jobs (useful for maintenance).

For a detailed record of the service, see:

  • journalctl -u cups
  • tail -f /var/log/cups/error_log

These records are essential to diagnose filter problems, permissions or communication with the printer.

Common problem solution

Although CUPS is robust, certain scenarios can generate failures. Below is a list of the most frequent problems and their solutions:

  • Printer not detected:Verifies that the device is connected and that the kernel recognizes it withlsusbordmesg. If it is a network printer, make sure it has a static IP and port 631 is accessible (nc -zv IP 631).
  • Work stuck in the tail:Uselpstat -oto see the jobs held. Then runcancel ID_DEL_TRABAJOor restart the service withsudo systemctl restart cups.
  • Missing filter error:Indicates that some backend or filter is missing (e.g.,foomatic-rip). Install the corresponding driver package (sudo apt install printer-driver-foo2zjs) or check the file/var/log/cups/error_logto identify the missing module.
  • Access denied from other equipment:Check the directiveincupsd.confand make sure the subnet is included. It also verifies that the firewall allows TCP traffic in port 631 (sudo firewall-cmd --add-service=ipp --permanentin firewall).
  • Slow printing or with scribbled characters:It may be due to an inadequate controller. Try changing the PDP to a more generic version (everywhere) or by downloading the manufacturer's specific controller from your website.

Maintaining the system up-to-date and periodically reviewing the logs helps prevent most of these disadvantages.

Conclusion and best practices

CUPS remains the backbone of printing in Linux environments thanks to its flexibility, support for multiple protocols and active community. To make the most of it, it considers following these practices:

  • Keep the service and driver packages up to date.
  • It documents the configuration of each printer (IP, PPD, options) in a wiki or internal repository.
  • Use sets of printers (lpadmin -p Grupo -v ipp://...) to simplify management in large offices.
  • Enable level registrationdebugonly when you need to solve a specific problem, and come back toinfoto avoid filling the disk.
  • Support the file/etc/cups/cupsd.confand the directory/etc/cups/ppdfacilitates migration to new servers.

With the steps described in this article, you will be able to install, configure, manage and solve CUPS problems in any Linux distribution, ensuring that printing is a reliable and transparent service for all users.

This work is under aCreative Commons License Attribution 4.0 International for Francesc Roig francesc @ vivaldi.net.

EnglishenEnglishEnglish