CUPS - ArchWiki

# CUPS

Related articles

- CUPS printer sharing
- CUPS printer-specific problems
- Samba
- LPRng
- CUPS/Troubleshooting

This article or section needs language, wiki syntax or style improvements.

Reason: The pages in Category:Printers need substantial reorganization and deduplication. (Discuss in Talk:CUPS#Rewrite)

This document covers the installation and maintenance of printers using CUPS. It covers local installation and networked installations. The document will consist of a brief introduction, followed by its two main components: installation and configuration of CUPS, followed by installation and configuration of a printer. Afterwards, applications related to the control of printing, as well as a method of controlling CUPS from the terminal, will be covered.

## Printing and Arch Linux

GNU/Linux has great support for printers; the right tool for the job is called CUPS (Common Unix Printing System). Since the beginning of the project, back in 1999, the installation and maintenance of CUPS has improved dramatically. In this document we will cover how to use CUPS to setup a local or networked printer. It will not go into too much detail since the project has great documentation available for advanced usage.

## Installing and Configuring CUPS

### Installation

Install the cups, ghostscript, and gsfonts packages.

If the system is connected to a networked printer using the Samba protocol, or if the system is to be a print server for Windows clients, also install samba. If you intend to "print" into a PDF document, install cups-pdf.

With CUPS installed, you can now start and enable `org.cups.cupsd.service`.

Optionally, CUPS can use Avahi browsing to discover unknown shared printers in your network. This can be useful in large setups where the server is unknown. To use this feature, start the `cups-browsed.service` systemd unit.

Install the libcups package.

Then add your CUPS server's IP address or hostname into `/etc/cups/client.conf`, after `ServerName`. Every application should now find the printer(s) shared by that CUPS server.

Create the printadmin group:

    # groupadd printadmin

and add the users to the group(s) (`man gpasswd`):

    # gpasswd -a username printadmin       # for printer administration
    # gpasswd -a username lp               # for printing priviledges

Then edit `/etc/cups/cups-files.conf`:

    /etc/cups/cups-files.conf

    SystemGroup sys root printadmin

Finally restart `org.cups.cupsd.service`. The user must re-login for these changes to take effect.

Refer to the full CUPS documentation for further details.

### Configuration

Note: This section covers configuration of CUPS specifically. For configuration related to printers, see #Installing and Configuring a Printer

The default CUPS server configuration located in /etc/cups/cupsd.conf is sufficient for most users. However, some users might need to make changes to the CUPS configuration.

Several changes that are often needed will be covered below:

- Allow other systems to use the printer attached to this GNU/Linux workstation.
- Grant access to the CUPS administration from remote systems.
- Configure CUPS to support Windows PCL drivers. This is advised for Windows systems to be able to use a SAMBA-shared printer since most Windows drivers are PCL drivers.
- Configure this system to use a printer attached to another system (not Windows share).

#### Remote Printer Access

For other systems to use the printer through IPP, explicit access to the printer must be granted in the /etc/cups/cupsd.conf file. To share the printer using SAMBA, this change is not needed.

Open up /etc/cups/cupsd.conf in a favorite text editor and add in an `Allow` line for the system(s) that should be able to reach to the printer. In the next example, access is granted to the printer from localhost and from any system whose IP address starts with `192.168.0`.

    /etc/cups/cupsd.conf

    <Location />
      Order allow,deny
      Allow localhost
      Allow from 192.168.0.*
    </Location>

This line broadcasts browsing information to the clients on the network; it will let network users know when the printer is available:

    /etc/cups/cupsd.conf

    BrowseAddress 192.168.0.*:631

The port CUPS listens to will also need to be specified so that it will respond to printing requests from other machines on the network:

    /etc/cups/cupsd.conf

    Listen *:631
    #Listen localhost:631

#### CUPS Remote Administration

If remote administration is needed, then access to the CUPS administration will need to be granted from more systems than the localhost. Edit the /etc/cups/cupsd.conf file and have explicit access granted to each system that requires access. For instance, to grant access to a system with an IP address of 192.168.0.3:

    /etc/cups/cupsd.conf

    <Location /admin>
    (...)
      Encryption Required
      Order allow,deny
      Allow localhost
      Allow 192.168.0.3
    </Location>

Do not forget to restart the CUPS daemon after making changes to /etc/cups/cupsd.conf.

#### Enable Support for Windows PCL Drivers

PCL drivers send raw data to the print server. To enable raw printing on CUPS, edit /usr/share/cups/mime/mime.types and uncomment the `application/octet-stream` line if it is not already uncommented. Then edit /usr/share/cups/mime/mime.convs and do the same, if it is not already uncommented.

    /usr/share/cups/mime/mime.types

    application/octet-stream

    /usr/share/cups/mime/mime.convs

    application/octet-stream     application/vnd.cups-raw    0    -

Do not forget to restart the CUPS daemon after making these changes.

#### Setting Up a Remote Printer

If the printers are attached to a remote CUPS-powered server the system can be easily configured to use the remote printer by modifying the /etc/cups/client.conf file.

Assuming the printer is attached to a system called `printserver.mydomain`, open up /etc/cups/client.conf}} with a favorite text editor and set the `ServerName` directive:

    /etc/cups/client.conf

    # (Substitute printserver.mydomain with your print server name)
    ServerName printserver.mydomain

The remote system will have a default printer setting which will be used. To change the default printer, use the lpoptions command.

First list the available printers:

    lpstat -a
     hpljet5p accepting requests since Jan 01 00:00
     hpdjet510 accepting requests since Jan 01 00:00

Set the HP LaserJet 5P as the default printer:

    lpoptions -d hpljet5p

## Installing and Configuring a Printer

### Remotely Available Printers

If the printer to be configured is remotely available through a different print server (running CUPS) then the following instructions are not needed. Instead, read Setting Up a Remote Printer.

### Detecting the Printer

If a USB printer or parallel port printer was powered on when the GNU/Linux system booted, it might be possible to retrieve information from the kernel stating successful detection of the printer. This is merely an indication of print detection and not a requirement.

    dmesg | grep -i print

    parport0: Printer, Hewlett-Packard HP LaserJet 2100 Series

For a USB printer:

    lsusb

    (...)
    Bus 001 Device 007: ID 03f0:1004 Hewlett-Packard DeskJet 970c/970cse

### Installing the Printer

To have the printer installed on the system, fire up a browser and point it to http://localhost:631. The CUPS web interface should be displayed from which all administrative tasks can be performed.

Note: If an HTTPS connection to CUPS is used the first time the interface is accessed it may take a very long time before the page appears. This is because the first request triggers the generation of CUPS SSL certificates which can be a time-consuming job.

Go to Administration and enter the root login and password information your GNU/Linux system. Then, when the administrative interface has been reached, click on Add Printer. A new screen will be displayed allowing the following information to be entered:

- The spooler name, a short but descriptive name used on the system to identify the printer. This name should not contain spaces or any special characters. For instance, for the HP LaserJet 5P could be titled `hpljet5p`.
- The location, a description where the printer is physically located (for instance "bedroom", or "in the kitchen right next to the dish washer", etc.). This is to aid in maintaining several printers.
- The description should contain a full description of the printer. A common use is the full printer name (like "HP LaserJet 5P").

The next screen requests the device the printer listens to. The choice of several devices will be presented. The next table covers a few possible devices, but the list is not exhaustive.

Device | Description
--- | ---
AppSocket/HP JetDirect | This special device allows for network printers to be accessible through a HP JetDirect socket. Only specific printers include support for this option.
Internet Printing Protocol (IPP or HTTP) | Used reach the remote printer through the IPP protocol either directly (IPP) or through HTTP.
LPD/LPR Host or Printer | Select this option if the printer is remote and attached to a LPD/LPR server.
Parallel Port #1 | Select when the printer is locally attached to a parallel port (LPT). When the printer is automatically detected its name will be appended to the device.
USB Printer #1 | Select when the printer is locally attached to a USB port. The printer name should automatically be appended to the device name.

If installing a remote printer, the URL to the printer will be queried:

- An LPD printer server requires a `lpd://hostname/queue` syntax.
- An HP JetDirect printer requires a `socket://hostname` syntax.
- An IPP printer requires a `ipp://hostname/printers/printername` or `http://hostname:631/printers/printername` syntax.

Next, select the printer manufacturer in the adjoining screen along with the model type and number in the subsequent screen. For many printers multiple drivers will be available. Select one now or search on OpenPrinting Printer List for a good driver. Drivers are easily able to be changed later.

Once the driver is selected, CUPS will inform that the printer has been added successfully to the system. Navigate to the printer management page on the administration interface and select Configure Printer to change the printer's settings (resolution, page format, ...).

### Testing and Reconfiguring the Printer

To verify if the printer is working correctly, go to the printer administration page, select the printer and click on Print Test Page.

If the printer does not seem to work correctly, click on Modify Printer to reconfigure the printer. The same screens as during the first installation will appear but the defaults will now be the current configuration.

If the printer does not function, clues may be found by looking at the CUPS error log located at /var/log/cups/error_log. In the next example a permission error is discovered, probably due to a wrong Allow setting in the /etc/cups/cupsd.conf file.

    tail /var/log/cups/error_log
     (...)
     E [11/Jun/2005:10:23:28 +0200] [Job 102] Unable to get printer status (client-error-forbidden)!

### Installing the Best Driver

Note: Prior to this step, see #Using Special Printer drivers, as your driver may be available in the official repositories, or in the AUR, which may save you time.

Many printer drivers exist. To find out which one has the best performance for your printer, visit the OpenPrinting Printer List. Select the brand and type/model of the printer to find out what driver the site recommends. For instance, for the HP LaserJet 5P, the site recommends the `ljet4` driver.

Download the PPD file from the site and place it in /usr/share/cups/model. Then restart the CUPS daemon. This will make the driver available through the CUPS web interface. Now reconfigure the printer as described above.

#### Using Special Printer drivers

This article or section needs language, wiki syntax or style improvements.

Reason: The Special Drivers sections needs to be reduced to include only drivers which do not exist as PPD files available in the previous step. (Discuss in Talk:CUPS#Rewrite)

Some printers require special drivers to unlock all of their functions. These drivers may not be available from the step mentioned above.

##### Foomatic

foomatic-db, foomatic-db-engine and foomatic-db-nonfree are database-driven systems for integrating free software printer drivers with common spoolers under Unix.

##### Gutenprint

The gutenprint drivers are high-quality, open source printer drivers for various Canon, Epson, HP, Lexmark, Sony, Olympus and PCL printers supporting CUPS. They also support ghostscript, The GIMP, and other applications.

Once finished installing, the gutenprint drivers will be available through the CUPS web interface.

##### Cannon

Driver | Description
--- | ---
cndrvcups-lbAUR | Canon UFR II /LIPSLX Printer Driver build from source for LBP, iR & MF printers
cndrvcups-lb-binAUR | Canon UFR II/UFR II LT Printer Driver (including Canon imageCLASS MF4720w)
cnijfilter-mg4200AUR | Canon IJ Printer Driver (for mg4200 series)
cups-bjnpAUR | CUPS back-end for the canon printers using the proprietary USB over IP BJNP protocol

##### Espon

epson-inkjet-printer-escprAUR is a driver for the Epson Inkjet Printer Driver (ESC/P-R) for Linux.

##### HP

Driver | Description
--- | ---
hplip | Drivers for HP DeskJet, OfficeJet, Photosmart, Business Inkjet and some LaserJet
hpojAUR | If problems occur using an HP Officejet, install this package and follow the instructions in this thread.
pnm2ppaAUR | For HP DeskJet 710C, 712C, 720C, 722C, 820Cse, 820Cxi, 1000Cse, or 1000Cxi printers.

###### HPLIP Driver

hplip provides drivers for HP DeskJet, OfficeJet, Photosmart, Business Inkjet and some LaserJet printers.

To run with qt frontend:

    # hp-setup -u

To run with command line:

    # hp-setup -i

To run systray spool manager:

    $ hp-systray

PPD files are in `/usr/share/ppd/HP/`.

For printers that require the proprietary HP plugin (like the Laserjet Pro P1102w or 1020), install the hplip-pluginAUR package from AUR.

Note:

hplip depends on foomatic-db-engine which prevents the drivers list from appearing when a printer is added to CUPS via the web user interface (following error : "Unable to get list of printer drivers"). Possible workarounds:

- Either: Install hplip first, then retrieve the PPD file that matches your printer from `/usr/share/ppd/HP/`. Next, remove hplip entirely as well as any unnecessary dependencies. Finally, install the printer manually using the CUPS web UI, selecting the PPD file you retrieved, and then re-install hplip. After a reboot, you should have a fully working printer.
- Or: Remove hplip, foomatic-db and foomatic-db-engine along with any unnecessary dependencies. Reinstall hplip and restart CUPS. Install your printer using the CUPS web UI, which should now be able to find the drivers automatically. No reboot needed.

##### Samsung

Driver | Description
--- | ---
samsung-unified-driverAUR | Unified Linux Driver for Samsung printers and scanners. Required for new printers such as the ML-2160.
splix | Samsung drivers for SPL (Samsung Printer Language) printers.

For printers requiring the cnijfilter drivers, search for the correct driver in the AUR

## Printing Related Applications

### GNOME

GNOME users can modify their printers in the Printers tab of the GNOME System Settings tool.

### KDE

KDE users can modify their printers in the Printers tab of the KDE System Settings tool. The print-manager package may need be installed if the Printers interface is not found in the Hardware group. KDE users should refer to the desktop environments' documentation for more information on how to use the interface.

### system-config-printer

You can configure and manage printers by installing the system-config-printer package.

If your user does not have sufficient privileges to administer the cups scheduler, system-config-printer will request the root password when it starts. Follow the installation steps to set up administrative privileges.

## Controlling CUPS from the Terminal

CUPS can be fully controlled from command-line with nice tools, i.e. the lp* and the cups* command families.

On Arch Linux, most commands support auto-completion with common shells. Also note that command-line switches cannot be grouped.

List the devices

    # lpinfo -v

List the drivers

    # lpinfo -m

Add a new printer

    # lpadmin -p printer -E -v device -P ppd

The printer is up to you. The device can be retrieved from the 'lpinfo -v' command. Example:

    # lpadmin -p HP_DESKJET_940C -E -v "usb://HP/DESKJET%20940C?serial=CN16E6C364BH"  -P /usr/share/ppd/HP/hp-deskjet_940c.ppd.gz

In the following, the printer references the name you have used here to set up the printer.

Set the default printer

    $ lpoptions -d printer

Check the status

    $ lpstat -s
    $ lpstat -p printer

Deactivate a printer

    # cupsdisable printer

Activate a printer

    # cupsenable printer

Remove a printer

First set it to reject all incoming entries:

    # cupsreject printer

Then disable it.

    # cupsdisable printer

Finally remove it.

    # lpadmin -x printer

Print a file

    $ lpr file
    $ lpr -# 17 file              # print the file 17 times
    $ echo "Hello, world!" | lpr -p # print the result of a command. The -p switch adds a header.

Check the printing queue

    $ lpq
    $ lpq -a # on all printers

Clear the printing queue

    # lprm   # remove last entry only
    # lprm - # remove all entries

## Troubleshooting

See CUPS/Troubleshooting.

## See also

- Official CUPS documentation, locally installed
- Official CUPS website
- OpenPrinting homepage

Note: This article borrows some portions from the Gentoo wiki page. For a full list of authors, see the following.

- Gentoo's printing guide

Category:

- Printers