CUPS
Related articles
CUPS is the standards-based, open source printing system developed by Apple Inc. for OS X® and other UNIX®-like operating systems.
Contents
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 the samba package.
If you intend to "print" into a PDF document, also install the cups-pdf package. By default, pdf files are stored in /var/spool/cups-pdf/$USER
. The location can be changed in /etc/cups/cups-pdf.conf
.
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 cups-browsed.service
.
Connection Interfaces
Before CUPS can attempt to use a printer, it must be able to detect the printer. Additional steps for printer detection are listed below for various connection interfaces.
USB
To see if your USB printer is detected:
lsusb
(...) Bus 001 Device 007: ID 03f0:1004 Hewlett-Packard DeskJet 970c/970cse
Parallel port
To use a parallel port printer, the lp
, parport
and parport_pc
kernel modules are required.
dmesg | grep -i print
parport0: Printer, Hewlett-Packard HP LaserJet 2100 Series lp0: using parport0 (polling)
If you are using a USB to parallel port adapter, add the printer using a different connection type and then change DeviceID in /etc/cups/printers.conf
:
DeviceID = parallel:/dev/usb/lp0
Local Network
Newer versions of CUPS tend to be good at detecting printers, and tend to pick the right hostname, but unless you have added the printer to your /etc/hosts, CUPS will fail to resolve for normal printer activities. Unless you want to make your printer ip static, Avahi can help autoresolve your printer hostname. Set up Avahi and .local hostname resolution then restart CUPS by restarting the org.cups.cupsd.service
systemd unit.
You can use avahi-discover
find the name of your printer and its address (ex. Address: BRN30055C6B4C7A.local/10.10.0.155:631) or just add .local to the hostname CUPS was using (ex. BRN30055C6B4C7A.local). Double check that everything is working with ping:
ping XXXXXX.local
should work, if it doesn't go back and make sure that Avahi is running and that you have the right hostname. After this, make sure that the hostname in the CUPS web interface is the .local hostname.
Printer Drivers
The drivers for a printer may come from any of the sources shown below. See CUPS/Printer-specific problems for a non-comprehensive list of drivers that others have gotten to work.
Usually CUPS requires either a prebuilt PPD file including the driver or some XML data files + a PPD file generating engine to work. Even when a PPD file is provided to CUPS, the CUPS server will install its own regenerated PPD file into /etc/cups/ppd/
CUPS Native Drivers
CUPS already includes a few printer drivers. In that case you can just select it in the list and your printer will likely work.
Foomatic
foomatic-db-engine + foomatic-db or foomatic-db-nonfree are database-driven systems for integrating software printer drivers with common spoolers under Unix.
foomatic-db-ppds or foomatic-db-nonfree-ppds provide prebuilt PPD files from manufacturers.
Note that foomatic only provides PPDs, not driver binaries. It can drive some printers using ghostscript, but other printers may need alternative drivers such as min12xxwAUR.
Gutenprint
The gutenprint, foomatic-db-gutenprint, foomatic-db-gutenprint-ppds 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.
OpenPrinting.org
There might be a PPD available at the OpenPrinting Printer List. Usually these driver files are included in the above foomatic packages. But searching for your printer model might help you decide which driver to chose from the list.
Select the brand and type/model of the printer to find out what driver the site recommends. Download the PPD file from the site. When the CUPS web interface asks for a printer driver/PPD, select "Or Provide a PPD File: Choose file".
The website will also suggest a driver. For instance, for the HP LaserJet 5P, the site recommends the ljet4
driver. It is possible that this driver is already included with CUPS, otherwise you will need to install it through another source listed in this section.
Manufacturer-specific drivers
Many printer manufacturers supply their own Linux drivers. These are often available in the official Arch repositories or in the AUR.
Some of those drivers are described in more detail in CUPS/Printer-specific problems.
Print Queues
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.
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.
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
orhttp://hostname:631/printers/printername
syntax.
Detection of local printers should be automatic, and the printer name should automatically be appended to the device name.
On the next screen, you can select the printer manufacturer along with the model type and number. Remember that you need to have downloaded/installed the correct printer driver in order to see your printer type among the others in the list. See the previous section on "Printer Drivers" to do this.
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, ...).
Remote CUPS servers
See CUPS/Troubleshooting#Networking issues for common issues.
Local CUPS server
Remote print servers can be accessed by adding an IPP "printer" to the local CUPS server, with a URI of ipp://192.168.0.101:631/printers/<name-of-printer>
.
See CUPS/Printer sharing#Between GNU/Linux systems for details on setting up the remote print server.
Without a local CUPS server
Install libcups. To print from some applications, you will also need to install cups.
There are currently two methods for accessing a remote print server.
The first method involves setting CUPS_SERVER
for each application, for instance for Firefox:
# (Substitute printserver.mydomain with your print server name) CUPS_SERVER=printserver.mydomain:port firefox
The second method involves editing /etc/cups/client.conf
and setting the ServerName
directive:
/etc/cups/client.conf
# (Substitute printserver.mydomain with your print server name) ServerName printserver.mydomain
The remote system's default printer setting will be used by default.
Configuration
The CUPS server configuration is located in /etc/cups/cupsd.conf
and /etc/cups/cups-files.conf
. After editing either file, restart org.cups.cupsd.service
to apply any changes. The default configuration is sufficient for most users.
Groups with printer administration privileges are defined in SystemGroup
in the /etc/cups/cups-files.conf
. The sys
group is used by default.
cups is built with libpaper support and libpaper defaults to Letter paper size. To avoid having to change paper size for each printer you add, edit /etc/papersize
and set your system default paper size. See papersize(5).
Printer sharing
See CUPS/Printer sharing.
Test 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 work, see CUPS/Troubleshooting.
Usage
CUPS can be fully controlled using the lp* and cups* command-line tools. Alternatively, several GUI applications exist.
CLI tools
See CUPS local documentation for more tips on the command-line tools.
- List the devices
# lpinfo -v
- List the drivers
# lpinfo -m
- Add a new printer
# lpadmin -p printer_name -E -v device -P ppd
The printer_name 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
- Make the printer use the raw driver
# lpadmin -p printer_name -m raw
- Set the default printer
$ lpoptions -d printer_name
- Check the status
$ lpstat -s $ lpstat -p printer_name
- Deactivate a printer
# cupsdisable printer_name
- Activate a printer
# cupsenable printer_name
- Remove a printer
First set it to reject all incoming entries:
# cupsreject printer_name
Then disable it.
# cupsdisable printer_name
Finally remove it.
# lpadmin -x printer_name
- 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
GUI applications
If your user does not have sufficient privileges to administer CUPS, the applications will request the root passwords when they start. To give users administrative privileges without needing root access, see #Configuration.
- print-manager — A tool for managing print jobs and printers (KDE).
- system-config-printer — A CUPS printer configuration tool and status applet (GNOME and others)
- gtklp — GTK+ interface to CUPS.
Troubleshooting
See CUPS/Troubleshooting.