Difference between revisions of "CUPS"

From ArchWiki
Jump to navigation Jump to search
(→‎Printer Drivers: link to talk)
 
(987 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
[[Category:Printers (English)]]
+
[[Category:Printers]]
[[Category:HOWTOs (English)]]
+
[[Category:Servers]]
{{i18n_links_start}}
+
[[cs:CUPS]]
{{i18n_entry|English|CUPS}}
+
[[de:CUPS]]
{{i18n_entry|Рolski|CUPS (Polski)}}
+
[[es:CUPS]]
{{i18n_entry|Русский|CUPS (Русский)}}
+
[[fr:CUPS]]
{{i18n_entry|Türkçe|CUPS (Türkçe)}}
+
[[it:CUPS]]
{{i18n_links_end}}
+
[[ja:CUPS]]
=Introduction=
+
[[pl:CUPS]]
 +
[[ru:CUPS]]
 +
[[th:CUPS]]
 +
[[zh-hans:CUPS]]
 +
[[zh-hant:CUPS]]
 +
{{Related articles start}}
 +
{{Related|CUPS/Printer sharing}}
 +
{{Related|CUPS/Printer-specific problems}}
 +
{{Related|CUPS/Troubleshooting}}
 +
{{Related|Samba}}
 +
{{Related|LPRng}}
 +
{{Related articles end}}
  
==What is CUPS?==
+
[https://www.cups.org/ CUPS] is the standards-based, open source printing system developed by Apple Inc. for macOS® and other UNIX®-like operating systems.
  
Straight from the CUPS website: "The Common UNIX Printing System ("CUPS") is a cross-platform printing solution for all UNIX environments. It is based on the "Internet Printing Protocol" and provides complete printing services to most Postscript and raster printers. CUPS is provided under the GNU GPL..."  Although there are other printing packages such as LPRNG, CUPS is quite popular and relatively easy to use.  It is the default printing system on Arch Linux as well as many other Linux distributions.
+
== Installation ==
  
==Troubleshooting CUPS & components==
+
[[Install]] the {{Pkg|cups}} package.
  
The best way to get printing working is to set 'LogLevel' in '/etc/cups/cupsd.conf' to:
+
If you intend to "print" into a PDF document, also install the {{pkg|cups-pdf}} package. By default, pdf files are stored in {{ic|/var/spool/cups-pdf/''username''/}}. The location can be changed in {{ic|/etc/cups/cups-pdf.conf}}.
<pre>
 
LogLevel debug
 
</pre>
 
And then viewing the output from '/var/log/cups/error_log' like this:
 
<pre>
 
# tail -n 100 -f /var/log/cups/error_log
 
</pre>
 
The characters at the left of the output stands for:
 
<pre>
 
D = Debug
 
E = Error
 
I = Information
 
etc...
 
</pre>
 
These files may also prove useful.
 
<pre>
 
/var/log/cups/page_log 'spits out a new entry each time a print is successful.'
 
/var/log/cups/access_log 'lists all cupsd http1.1 server activity'
 
</pre>
 
  
Of course it's important to know how CUPS work if you want to solve your problems, this is somewhat correct:
+
[[Enable]] and [[start]] {{ic|org.cups.cupsd.service}}.
  
# An application sends a .ps file (PostScript, a script language that details how the page will look) to CUPS when you select 'print' (99% of apps do).
+
=== Socket activation ===
# CUPS then looks at your printers PPD file (printer description file) and figures out what filters it needs to use to convert the .ps file to a language that the printer understands (like PJL,PCL).  Usually it needs ghostscript.
 
# GhostScript takes the input and figures out which filters it should use, then applies them and converts the .ps file to a format understood by the printer.
 
# Then it is sent to the backend.  For example, if you have your printer connected to a USB port, it uses the USB backend.
 
  
Print a document and watch 'error_log' to get a more detailed and correct image of the printing process.
+
{{Pkg|cups}} provides a {{ic|org.cups.cupsd.socket}} unit. If {{ic|org.cups.cupsd.socket}} is [[enable]]d (and {{ic|org.cups.cupsd.service}} is [[disable]]d), systemd will not start CUPS immediately, it will just listen to the appropriate sockets. Then, whenever a program attempts to connect to one of these CUPS sockets, systemd will start {{ic|org.cups.cupsd.service}} and transparently hand over control of these ports to the CUPS process.
  
=Installing CUPS=
+
This way, CUPS is only started once a program wants to make use of the service.
  
==Packages==
+
== Connection Interfaces ==
  
You will need CUPS and Ghostscript for sure:
+
Additional steps for printer detection are listed below for various connection interfaces.
# pacman -S cups ghostscript gsfonts
 
  
* <b>cups</b> - The actual CUPS software
+
{{Note|1=<nowiki></nowiki>
* <b>dbus-core</b> - The dbus library is needed for cups
+
* CUPS helper programs are run using the {{ic|cups}} user and group. This allows the helper programs to access printer devices and read config files in {{ic|/etc/cups/}}, which are owned by the {{ic|cups}} group.
* <b>ghostscript</b> - An interpreter for the Postscript language
+
* Prior to {{Pkg|cups}} 2.2.6-2, the {{ic|lp}} group [https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/cups&id=a209bf21797a239c7ddb4614f0266ba1e5238622 was used instead]. After the upgrade, the files in {{ic|/etc/cups}} should be owned by the {{ic|cups}} group and {{ic|User 209}} and {{ic|Group 209}} set in {{ic|/etc/cups/cups-files.conf}}.
* <b>gsfonts</b> - Ghostscript standard Type1 fonts
+
}}
  
 +
=== USB ===
  
Here are some of the following driver packages; choosing the right driver depends on the printer you own. If unsure, install gutenprint.
+
To see if your USB printer is detected:
  
* <b>gutenprint</b> - A collection of high quality drivers for Canon, Epson, Lexmark, Sony, Olympus, and PCL printers for use with Ghostscript, CUPS, Foomatic, and the Gimp.
+
{{hc|$ lsusb|
* <b>foomatic-db</b>, <b>foomatic-db-engine</b>, <b>foomatic-db-nonfree</b> and <b>foomatic-filters</b> - Foomatic is a database-driven system for integrating free software printer drivers with common spoolers under Unix
+
(...)
* Installing <b>foomatic-filters</b> should solve your problems if the cups error_log is reporting "stopped with status 22!"
+
Bus 001 Device 007: ID 03f0:1004 Hewlett-Packard DeskJet 970c/970cse
* <b>hplip</b> and <b>net-snmp</b> - HP Linux inkjet driver. Provides support for DeskJet, OfficeJet, Photosmart, Business Inkjet and some LaserJet printer models. <i>net-snmp</i> should be listed as a dependency but is not as of this writing, so you should manually install it along with <i>hplip</i>.
+
}}
* <b>ufr2</b> - Canon UFR2 driver with support for LBP, iR and MF series printers. Package is available in AUR.
 
* <b>cups-pdf</b> - A nice package that allows one to setup a virtual PDF Printer that generates a PDF out of anything sent to it.
 
  
 +
=== Parallel port ===
  
If your system is connected to a networked printer using the samba protocol or if the system is to be a print server for Windows clients:
+
To use a parallel port printer, the {{ic|lp}}, {{ic|parport}} and {{ic|parport_pc}} [[kernel modules]] are required.
# pacman -S samba
 
  
==Download Printer PPD==
+
{{hc|$ dmesg {{!}} grep -i parport|
 +
parport0: Printer, Hewlett-Packard HP LaserJet 2100 Series
 +
lp0: using parport0 (polling)
 +
}}
  
Depending on your printer, this step is optional and may not be needed, as the standard CUPS installation already comes with quite a few PPD (Postscript Printer Description) files. Moreover, the <i>foomatic-filters</i>, <i>gimp-print</i> and <i>hplip</i> packages already include quite a few PPD files which will automatically be detected by CUPS.
+
=== Network ===
  
 +
To discover or share printers using DNS-SD/mDNS, setup [[Avahi#Hostname_resolution|.local hostname resolution]] with [[Avahi]] and [[restart]] {{ic|org.cups.cupsd.service}}.
  
Here's an explanation of what a PPD file is from the Linux Printing website: "For every PostScript printer the manufacturers provide a PPD file which contains all printer-specific information about the particular printer model: Basic printer capabilities as whether the printer is a color printer, fonts, PostScript level, etc., and especially the user-adjustable options, as paper size, resolution, etc."
+
{{Note|DNS-SD is only supported when using [[Avahi]]. CUPS does not support using [[systemd-resolved]] for DNS-SD, see [https://github.com/apple/cups/issues/5452 CUPS issue 5452].}}
  
 +
To share printers with [[Samba]], e.g. if the system is to be a print server for Windows clients, the {{Pkg|samba}} package will be required.
  
*To get the PPD file for your printer, go to http://www.linuxprinting.org/printer_list.cgi and select the manufacturer and model of your printer.
+
== Printer Drivers ==
  
 +
{{Expansion|CUPS is planning to drop PPD and driver support ([https://github.com/apple/cups/issues/5271 CUPS issue 5271]), instead relying entirely on IPP Everywhere. Explain what is/will be handled by {{Pkg|cups}} and what by {{Pkg|cups-filters}} and/or other software.|section=CUPS printer drivers and backends are deprecated}}
  
*Now, you will need to copy the file to the cups folder so it can detect the file. If you are in the folder where you downloaded the PPD file, you can use the following command:
 
  
<pre>
+
The drivers for a printer may come from any of the sources shown below. See [[CUPS/Printer-specific problems]] for an incomplete list of drivers that others have managed to get working.
# cp your_printer.ppd /usr/share/cups/model/
 
</pre>
 
  
 +
To drive a printer, CUPS needs a PPD file and, for most printers, some [https://www.cups.org/doc/man-filter.html filters].
 +
For details on how CUPS uses PPDs and filters, see [https://www.cups.org/doc/postscript-driver.html].
  
If you cannot find your printer on the website, you may want to try similar models or using generic printer drivers. Just do some googling or ask your manufacturer (good luck with that).
+
The [http://www.openprinting.org/printers OpenPrinting Printer List] provides driver recommendations for many printers. It also supplies PPD files for each printer, but most are available through [[#Foomatic|foomatic]] or the recommended driver package.
  
=Configuring Cups=
+
When a PPD file is provided to CUPS, the CUPS server will regenerate the PPD files and save them in {{ic|/etc/cups/ppd/}}.
  
==Options==
+
=== CUPS ===
  
Now that you have cups installed, you have a variety of options on how to setup CUPS. You can always use the tried and true command line. Likewise, various desktop environments such as GNOME and KDE have useful programs that can help you manage your printers.  However, in order to make this process easy for the largest amount of users, we will use the web interface provided by CUPS.
+
CUPS includes support for [[wikipedia:AirPrint|AirPrint]] and [http://www.pwg.org/ipp/everywhere.html IPP Everywhere] printers.
  
Please note that if you are planning on connecting to a network printer, rather than one that is directly connected to your computer, you may wish to jump to the Printer Sharing section first.  Linux to Linux printer sharing is quite easy and involves very little configuration.  Windows to Linux and vice-versa requires a little bit more effort, but is relatively easy as well.
+
=== OpenPrinting CUPS filters ===
  
==Kernel Modules==
+
The Linux Foundation's OpenPrinting workgroup provides [https://wiki.linuxfoundation.org/openprinting/cups-filters cups-filters]. Those are backends, filters, and other binaries that were once part of CUPS but are no longer maintained by Apple. They are available in the {{Pkg|cups-filters}} package that is a dependency of {{Pkg|cups}}.
  
Before we can use the CUPS web interface, we must install the appropriate kernel modules. The following are steps that I got from the Gentoo Printing Guide.
+
Non-PDF printers require {{pkg|ghostscript}} to be installed. For PostScript printers {{Pkg|gsfonts}} may also be required.
===USB printers===
 
If you want to use a USB printer with a 2.6.x kernel, use the following command:
 
  
<pre>
+
=== Foomatic ===
# modprobe usblp
 
</pre>
 
  
If you are using a USB printer and a 2.4.x kernel, use the following command:
+
The Linux Foundation's OpenPrinting workgroup's [https://wiki.linuxfoundation.org/openprinting/database/foomatic foomatic] provides PPDs for many printer drivers, both free and nonfree. For more information about what foomatic does, see [http://www.openprinting.org/download/kpfeifle/LinuxKongress2002/Tutorial/IV.Foomatic-Developer/IV.tutorial-handout-foomatic-development.html Foomatic from the Developer's View].
  
<pre>
+
To use foomatic, install {{pkg|foomatic-db-engine}} and at least one of:
# modprobe printer
 
</pre>
 
  
Note, this assumes that you are using the stock kernels from Arch Linux. If you custom-rolled your own, you may need to run this first:
+
* {{pkg|foomatic-db}} - a collection of XML files used by foomatic-db-engine to generate PPD files.
 +
* {{pkg|foomatic-db-ppds}} - prebuilt PPD files.
 +
* {{Pkg|foomatic-db-nonfree}} - a collection of XML files from printer manufacturers under non-free licenses used by foomatic-db-engine to generate PPD files.
 +
* {{pkg|foomatic-db-nonfree-ppds}} - prebuilt PPD files under non-free licenses.
  
<pre>
+
The foomatic PPDs may require additional filters, such as {{aur|min12xxw}}.
# modprobe usbcore
 
</pre>
 
  
Once you have the modules installed, you should plug in your printer and check if the kernel detected it by running the following:
+
=== Gutenprint ===
  
<pre>
+
The [http://gimp-print.sourceforge.net/ Gutenprint project] provides drivers for Canon, Epson, Lexmark, Sony, Olympus, and PCL printers for use with CUPS and [[GIMP]].
# tail /var/log/messages.log
 
</pre>
 
  
or
+
Install {{Pkg|gutenprint}} and {{Pkg|foomatic-db-gutenprint-ppds}}.
  
<pre>
+
{{Note|When the Gutenprint packages get updated, the printers using Gutenprint drivers will stop working until you run {{ic|cups-genppdupdate}} as root and restart CUPS. ''cups-genppdupdate'' will update the PPD files of the configured printers, see {{man|8|cups-genppdupdate}} for more details.}}
# dmesg
 
</pre>
 
  
 +
=== Manufacturer-specific drivers ===
  
You should see something like this:
+
Many printer manufacturers supply their own Linux drivers. These are often available in the official Arch repositories or in the [[AUR]].
  
<pre>
+
Some of those drivers are described in more detail in [[CUPS/Printer-specific problems]].
Feb 19 20:17:11 kernel: printer.c: usblp0: USB Bidirectional
 
printer dev 2 if 0 alt 0 proto 2 vid 0x04E8 pid 0x300E
 
Feb 19 20:17:11 kernel: usb.c: usblp driver claimed interface cfef3920
 
Feb 19 20:17:11 kernel: printer.c: v0.13: USB Printer Device Class driver
 
</pre>
 
  
===Parallel port printers===
+
== Printer URI ==
If you plan on using a parallel port printer, the configuration is pretty much the same.  Kernel 2.6.x users have to first type in:
 
  
<pre>
+
Listed below are additional steps to manually generate the URI if required. Some printers or drivers may need a special URI as described in [[CUPS/Printer-specific problems]].
# modprobe lp
 
</pre>
 
  
And then both 2.4.x and 2.6.x kernel users can enter in:
+
=== USB ===
  
<pre>
+
CUPS should be able to automatically generate a URI for USB printers, for example {{ic|1=usb://HP/DESKJET%20940C?serial=CN16E6C364BH}}.
# modprobe parport
 
# modprobe parport_pc
 
</pre>
 
  
Once again, you can check your setup by running:
+
If it does not, see [[CUPS/Troubleshooting#USB printers]] for troubleshooting steps.
# tail /var/log/messages.log
 
You should see something like this:
 
  
<pre>
+
=== Parallel port ===
lp0: using parport0 (polling).
 
</pre>
 
  
 +
The URI should be of the form {{ic|parallel:''device''}}. For instance, if the printer is connected on {{ic|/dev/lp0}}, use {{ic|parallel:/dev/lp0}}.
 +
If you are using a USB to parallel port adapter, use {{ic|parallel:/dev/usb/lp0}} as the printer URI.
  
Note: Installing my Brother HL 1250 I found that permissions for the device won't let CUPS write on the device, so it doesn't print. To fix it:
+
=== Network ===
  
<pre>
+
If you have set up [[Avahi]] as in [[#Network]], CUPS should detect the printer URI. You can also use {{ic|avahi-discover}} to find the name of your printer and its address (for instance, {{ic|BRN30055C6B4C7A.local/10.10.0.155:631}}).
[root@mihal ~]# ls /dev/usb/
 
lp0
 
[root@mihal ~]# chgrp lp /dev/usb/lp0
 
  
</pre>
+
The URI can also be generated manually, without using [[Avahi]].
 +
A list of the available URI schemes for networked printers is available in the [https://www.cups.org/doc/network.html#PROTOCOLS CUPS documentation]. As exact details of the URIs differ between printers, check either the manual of the printer or [[CUPS/Printer-specific problems]].
  
===Auto-loading===
+
The URI for printers on [[SMB]] shares is described in the {{man|8|smbspool}} man page.
You may also want to have the system automatically load the kernel module every time the computer starts up.  To do this use your favorite text editor to open up <code>/etc/rc.conf</code>  and add the appropriate module to the <i>MODULES=()</i> line.  Here's a portion of the text from my <code>rc.conf</code> file:
 
  
<pre>
+
{{Note|Any special characters in the printer URIs need to be appropriately quoted, or, if your Windows printer name or user passwords have spaces, CUPS will throw a {{ic|lpadmin: Bad device-uri}} error.
MODULES=(!usbserial scsi_mod sd_mod snd-ymfpci snd-pcm-oss lp parport parport_pc ide-scsi)
+
For example, {{ic|smb://BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6}} becomes {{ic|smb://BEN-DESKTOP/HP%20Color%20LaserJet%20CP1510%20series%20PCL6}}.
</pre>
+
 
 
+
This result string can be obtained by running the following command:
==CUPS Daemon==
 
 
 
With the kernel modules installed, you are now ready to start the actual CUPS daemon.  To do this, simply run this command as root:
 
  
<pre>
+
  $ python -c 'from urllib.parse import quote; print("smb://" + quote("BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6"))'
  # /etc/rc.d/cups start
 
</pre>
 
  
If you want to have cups start up automatically every time you start your computer, then you need to add it to your DAEMONS=() line in the <code>/etc/rc.conf</code> file.  For example:
+
}}
  
<pre>
+
Remote CUPS print servers can be accessed through a URI of the form {{ic|ipp://''hostname'':631/printers/''queue_name''}}. See [[CUPS/Printer sharing#Printer sharing]] for details on setting up the remote print server.
DAEMONS=(pcmcia syslogd klogd !fam esd mono network autofs cups crond gdm)
 
</pre>
 
  
==Web Interface and tool kit.==
+
See [[CUPS/Troubleshooting#Networking issues]] for additional issues and solutions.
  
Once the daemon is running, if a web interface is available. Open up your browser and go to:
+
{{Warning|1=Avoid configuring both the server and the client with a printer filter - either the print queue on the client or the server should be 'raw'. This avoids sending a print job through the filters for a printer twice, which can cause problems (for instance, [https://bbs.archlinux.org/viewtopic.php?pid=1589908#p1589908]). See [[#Usage]] for an example of setting a print queue to 'raw'.}}
  
<i>http://localhost:631</i>
+
== Usage ==
  
(You may need to replace ''localhost'' with your hostname found in <code>/etc/hosts</code>)
+
CUPS can be fully controlled using the lp* and cups* CLI tools.
 +
Alternatively, the [[#Web interface]] or one of several [[#GUI applications]] can be used.
  
'''or''' install "GNOME CUPS Manager" GUI frontend (see Appendix: A.1 [http://wiki.archlinux.org/index.php/CUPS_Setup#Alternative_CUPS_Interfaces Alternative CUPS Interfaces])
+
* The ''queue'' name is a short but descriptive name used on the system to identify the queue. This name should not contain spaces or any special characters. For instance, a print queue corresponding to a HP LaserJet 5P could be named "hpljet5p". More than one queue can be associated with each physical printer.
 +
* The ''location'' is a description of the printer's physical location (for instance "bedroom", or "kitchen"). This is to aid in maintaining several printers.
 +
* The ''description'' is a full description of the print queue. A common use is a full printer name (like "HP LaserJet 5P").
  
From here, all you have to do is follow the various wizards to add your printer.  To setup my Samsung ML-1250 printer, I started out by clicking on <i>Manage Printers</i>, and then <i>Add Printer</i>.  I was then prompted for a username and password.  I just logged in as root.  I entered in ml1250 for my printer name, My Room for location and then Peter's Samsung ML-1250 Laster Printer for description.  Next you will select the device.  Since my printer is a USB device, I just selected <i>USB Printer #1</i>.  The name of my printer also showed up next to the label <i>USB Printer #1</i>, so look for that.  Next, I simply chose the appropriate drivers and the installation was complete.
+
=== CLI tools ===
  
Once the installation is complete, you can test your configuration by pressing the Print Test Page button.
+
See [http://localhost:631/help/options.html CUPS local documentation] for more tips on the command-line tools.
  
===CUPS Administration===
+
{{Note|Command-line switches cannot be grouped}}
A username and password will be required when you administrate your printer in the web interface, such as: adding or removing printers, stopping print task, etc. The default username is the username in the sys group, or the root (you can change this by editing '''/etc/cups/cupsd.conf''' in the line of '''SystemGroup''').
 
  
If the root account has been locked, you cannot log in the CUPS administration interface by the default username and passwd. Then, you may need to change the default SystemGroup in cupsd.conf, and read '''''[http://bbs.archlinux.org/viewtopic.php?id=35567 this post]'''''.
+
{{Style|Nonstandard use of definition lists, comments in command line.}}
  
===Remote Access to Web Interface===
+
;List the devices
By default the CUPS web interface can only be accessed by the ''localhost''; i.e. the computer that it is installed on.  To remotely access the interface make the following changes to the /etc/cups/cupsd.conf file.  Replace the line
+
  # lpinfo -v
  Listen localhost:631
+
  $ /usr/lib/cups/backend/snmp ''ip_address''  # Use SNMP to find a URI
with
 
  port 631
 
so that CUPS will listen to incoming requests.  There are three levels of access that can be granted:
 
<Location />         #access to the server
 
<Location /admin> #access to the admin pages
 
<Location /admin/conf> #access to configuration files
 
To give remote hosts access to one of these levels add an '''Allow''' statement to that level’s section. An '''Allow''' statement can take one or more of the forms listed below:
 
  Allow all
 
Allow host.domain.com
 
Allow *.domain.com
 
Allow ip-address
 
Allow ip-address/netmask
 
Deny statements can also be used.  For example if I wanted to give all hosts on the 192.168.1.0/255.255.255.0 subnet full access, my /etc/cups/cupsd.conf file would include this:
 
  
# Restrict access to the server...
+
;List the models
# By default only localhost connections are possible
+
  $ lpinfo -m
<Location />
 
  Order allow,deny
 
  Allow From localhost
 
  '''Allow From 192.168.1.0/255.255.255.0'''
 
</Location>
 
 
# Restrict access to the admin pages...
 
<Location /admin>
 
  # Encryption disabled by default
 
    #Encryption Required
 
  Order allow,deny
 
  Allow From localhost
 
  '''Allow From 192.168.1.0/255.255.255.0'''
 
</Location>
 
 
# Restrict access to configuration files...
 
<Location /admin/conf>
 
  AuthType Basic
 
  Require user @SYSTEM
 
    Order allow,deny
 
  Allow From localhost
 
  '''Allow From 192.168.1.0/255.255.255.0'''
 
  </Location>
 
  
=Printer Sharing=
+
;Add a new queue
 +
# lpadmin -p ''queue_name'' -E -v ''uri'' -m ''model''
  
==Linux to Linux==
+
The ''queue_name'' is up to you.
 +
Examples:
 +
# lpadmin -p HP_DESKJET_940C -E -v "usb://HP/DESKJET%20940C?serial=CN16E6C364BH" -m drv:///HP/hp-deskjet_940c.ppd.gz
 +
# lpadmin -p AirPrint -E -v "ipp://10.0.1.25/ipp/print" -m everywhere    # Driverless queue (Apple AirPrint or IPP Everywhere)
 +
# lpadmin -p SHARED_PRINTER -m raw    # Raw queue; no PPD or filter
 +
# lpadmin -p Test_Printer -E -v "ipp://10.0.1.3/ipp/print" -m pxlmono.ppd    # Specifying a PPD instead of a model
  
Once you have CUPS setup on your Linux print server, sharing the printer with another Linux box is relatively easy. There are several ways to configure such a scenario -- here we will describe the manual setup. On the server computer (the one managing and connecting to the printer) simply open up <code>/etc/cups/cupsd.conf</code> and allow access to the server by modifying the location lines. For instance:
+
{{Note|When specifying the PPD, use just the file name and not the full path (for instance, {{ic|pxlmono.ppd}} instead of {{ic|/usr/share/ppd/cupsfilters/pxlmono.ppd}}). Alternatively, the full path can be used with the {{ic|-P}} command line switch.}}
  
<pre>
+
;Set the default printer
<Location />
+
$ lpoptions -d ''queue_name''
  Order allow,deny
 
  Allow localhost
 
  Allow 192.168.0.*
 
</Location>
 
</pre>
 
  
You will also need to make sure the server is listening on the IP address your client will be addressing. Add the following line after "# Listen <yourserverip>:631":
+
;Change the options
 +
$ lpoptions -p ''queue_name'' -l # List the options
 +
  $ lpoptions -p ''queue_name'' -o ''option''=''value'' # Set an option
  
<pre>
+
Example:
Listen 192.168.0.101:631
+
$ lpoptions -p HP_DESKJET_940C -o PageSize=A4
</pre>
 
  
using your server's IP address instead of client's 192.168.0.100
+
;Check the status
 +
$ lpstat -s
 +
$ lpstat -p ''queue_name''
  
To "Show shared printers on the local network" add the line "BrowseAllow all":
+
;Deactivate a printer
 +
# cupsdisable ''queue_name''
  
<pre>
+
;Activate a printer
Browsing On
+
# cupsenable ''queue_name''
BrowseOrder allow,deny
 
BrowseAllow @LOCAL
 
BrowseAllow all
 
</pre>
 
  
After you make your modifications, you will want to restart CUPS by doing:
+
;Set the printer to accept jobs
 +
# cupsaccept ''queue_name''
  
<pre>
+
;Remove a printer
  # /etc/rc.d/cups restart
+
First set it to reject all incoming entries:
</pre>
+
  # cupsreject ''queue_name''
 +
Then disable it.
 +
# cupsdisable ''queue_name''
 +
Finally remove it.
 +
# lpadmin -x ''queue_name''
  
On the client side, open up <code>/etc/cups/cupsd.conf</code> and add the ServerName to match the IP address or the name of your server. Add this line:
+
;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.
  
<pre>
+
;Check the queue
ServerName 192.168.0.101
+
$ lpq
</pre>
+
$ lpq -a # on all queues
  
There are more configuration possibilities including an automatic configuration which are described in detail on http://localhost:631/sam.html#CLIENT_SETUP (this link works on your printer server).
+
;Clear the queue
 +
# lprm  # remove last entry only
 +
# lprm - # remove all entries
  
When prompted for username and password, use root to access.
+
;View ink levels
Then follow the instructions from here
+
Install {{aur|ink}}.
http://www.digitalhermit.com/linux/printing/
 
if it's a TCP/IP printer, use JetDirect.
 
  
That's it for Linux to Linux printer sharing.
+
Add your user to the {{ic|lp}} [[user group]]:
 +
# usermod -aG lp <user>
  
==Linux to Windows==
+
Log out and log in again.
  
If you are connected to a Windows print server (or any other Samba capable print server), you can skip the section about kernel modules and such. All you have to do is start the CUPS daemon and complete the web interface as specified in section 3.3 and 3.4.  Before this, you need to activate the Samba CUPS backend.  You can do this by entering the following command:
+
For usage information, use:
 +
  $ ink
  
<pre>
+
=== Web interface ===
# ln -s `which smbspool` /usr/lib/cups/backend/smb
 
</pre>
 
  
Note that the symbol before is ` (underneath the ~ on a standard US keyboard) and not '.  After this, you will have to restart CUPS using the command specified in the previous section.  Next, simply log in on the CUPS web interface and choose to add a new printer.  As a device choose "Windows Printer via SAMBA".
+
The CUPS server can be fully administered through the web interface, available on http://localhost:631/.
  
For the device location, enter:
+
{{Note|If an HTTPS connection to CUPS is used, it ''may'' take a very long time before the interface appears the first time it is accessed. This is because the first request triggers the generation of SSL certificates which can be a time-consuming job.}}
  
<pre>
+
To perform administrative tasks from the web interface authentication is required. Authenticate either as {{ic|root}} or make sure your user is member of a group with printer administration privileges, see [[#Configuration]].
smb://username:password@hostname/printer_name
 
</pre>
 
  
Or without a password:
+
;Add a queue
 +
Go to the '''Administration''' page.
  
<pre>
+
;Modify existing queues
smb://username@hostname/printer_name
+
Go to the '''Printers''' page, and select a queue to modify.
</pre>
 
  
Make sure that the user actually has access to the printer on the Windows computer.  Select the appropriate drivers and that's about it. If the computer is located on a domain, make sure the username includes the domain:
+
;Test a queue
<pre>
+
Go to the '''Printers''' page, and select a queue.
smb://username:password@domain/hostname/printer_name
 
</pre>
 
  
Note: If your network contains many printers, use "lpoptions -d your_desired_default_printer_name" to set your preferred printer
+
=== GUI applications ===
  
Note: I, thepizzaking, was having 'NT_STATUS_ACCESS_DENIED' errors and to fix them I needed to use a slightly different syntax:
+
If your user does not have sufficient privileges to administer CUPS, the applications will request the root password when they start. To give users administrative privileges without needing root access, see [[#Configuration]].
<pre>
 
smb://workgroup/username:password@hostname/printer_name
 
</pre>
 
  
==Windows to Linux==
+
* {{App|GtkLP|GTK interface for CUPS.|https://gtklp.sirtobi.com/index.shtml|{{AUR|gtklp}}}}
 +
* {{App|print-manager|Tool for managing print jobs and printers ([[KDE]]).|https://cgit.kde.org/print-manager.git|{{Pkg|print-manager}}}}
 +
* {{App|system-config-printer|GTK printer configuration tool and status applet.|http://cyberelk.net/tim/software/system-config-printer/|{{Pkg|system-config-printer}}}}
  
Sometimes you might want to allow a Windows computer to connect to your Linux server.  There are a few ways to do this, and the one I am most familiar with is using Samba.  In order to do this, you will have to edit your <code>/etc/samba/smb.conf</code> file to allow access to your printers.  Your <code>smb.conf</code> can look something like this:
+
== Configuration ==
  
<pre>
+
The CUPS server configuration is located in {{ic|/etc/cups/cupsd.conf}} and {{ic|/etc/cups/cups-files.conf}} (see {{man|5|cupsd.conf}} and {{man|5|cups-files.conf}}). After editing either file, [[restart]] {{ic|org.cups.cupsd.service}} to apply any changes. The default configuration is sufficient for most users.
[global]
 
workgroup = Heroes
 
server string = Arch Linux Print Server
 
security = user
 
  
[printers]
+
[[User group]]s with printer administration privileges are defined in {{ic|SystemGroup}} in the {{ic|/etc/cups/cups-files.conf}}. The {{ic|sys}} and {{ic|root}} and {{ic|wheel}} [[groups]] are used by default.
    comment = All Printers
 
    path = /var/spool/samba
 
    browseable = yes
 
    # to allow user 'guest account' to print.
 
    guest ok = no
 
    writable = no
 
    printable = yes
 
    create mode = 0700
 
    write list = @adm root neocephas
 
</pre>
 
  
That should be enough to share your printer, but you just might want to add an individual printer entry:
+
{{pkg|cups}} is built with {{pkg|libpaper}} support and libpaper defaults to the '''Letter''' paper size. To avoid having to change the paper size for each print queue you add, edit {{ic|/etc/papersize}} and set your system default paper size. See {{man|5|papersize}}.
 
 
<pre>
 
[ML1250]
 
    comment = Samsung ML-1250 Laser Printer
 
    printer=ml1250
 
    path = /var/spool/samba
 
    printing = cups
 
    printable = yes
 
    printer admin = @admin root neocephas
 
    user client driver = yes
 
    # to allow user 'guest account' to print.
 
    guest ok = no
 
    writable = no
 
    write list = @adm root neocephas
 
    valid users = @adm root neocephas
 
</pre>
 
 
 
Please note that in my configuration I made it so that users must have a valid account to access the printer.  To have a public printer, set ''guest ok'' to ''yes'', and remove the ''valid users'' line. To add accounts, you must set up a regular Linux account and then set up a Samba password on the server.  For instance:
 
 
 
<pre>
 
# useradd neocephas
 
# smbpasswd -a neocephas
 
</pre>
 
 
 
After setting up any user accounts that you need, you will also need to set up the samba spool directory:
 
 
 
<pre>
 
# mkdir /var/spool/samba
 
# chmod 777 /var/spool/samba
 
</pre>
 
 
 
The next items that need changing are <code>/etc/cups/mime.convs</code> and <code>/etc/cups/mime.types</code>:
 
 
 
<code>mime.convs</code>:
 
<pre>
 
# The following line is found at near the end of the file. Uncomment it.
 
application/octet-stream        application/vnd.cups-raw        0      -
 
</pre>
 
 
 
<code>mime.types</code>:
 
<pre>
 
# Again near the end of the file.
 
application/octet-stream
 
</pre>
 
 
 
The changes to <code>mime.convs</code> and <code>mime.types</code> are needed to make CUPS print Microsoft Office document files. Many people seem to need that.
 
 
 
After this, restart your Samba daemon:
 
 
 
<pre>
 
# /etc/rc.d/samba restart
 
</pre>
 
 
 
Obviously there are a lot of tweaks and customizations that can be done with setting up a Samba print server, so I advise you to look at the Samba and CUPS documentation for more help.  The <code>smb.conf.example</code> file also has some good samples to that you might want to look at.
 
 
 
==Windows 2000 and Windows XP to Linux==
 
 
 
For the most modern flavors of Windows, an alternative way of connecting to your Linux printer server is to use the CUPS protocol directly.  The Windows client will need to be using Windows 2000 or Windows XP.  Make sure you allow the clients to access the print server by editing the location settings as specified in section 4.1.
 
 
 
On the Windows computer, go to the printer control panel and choose to Add a New Printer.  Next, choose to give a URL.  For the URL, type in the location of your printer:
 
 
 
<i>http://host_ip_address:631/printers/printer_name</i>
 
 
 
where host_ip_address is the Linux server's IP address and printer_name is the name of the printer you are connecting to.  After this, install the printer drivers for the Windows computer.  If you setup the CUPS server to use its own printer drivers, then you can just select a generic postscript printer for the Windows client.  You can then test your print setup by printing a test page.
 
 
 
==Others to Linux, Linux to others==
 
 
 
More information on interfacing CUPS with other printing systems can be found in the CUPS manual, e.g. on http://localhost:631/sam.html#PRINTING_OTHER
 
 
 
=Appendix=
 
 
 
==Alternative CUPS Interfaces==
 
 
 
If you are a [[GNOME]] user, you can manage and configure your printer by using the gnome-cups-manager. This package is available through pacman if you have the "community" repository uncommented in <code>/etc/pacman.conf</code>.
 
 
 
<pre>
 
# pacman -S gnome-cups-manager
 
</pre>
 
 
 
Alternatively, you may also install system-config-printer-gnome from the "community" repository:
 
 
 
<pre>
 
# pacman -S system-config-printer-gnome
 
</pre>
 
 
 
For system-config-printer to work as it should you may run as root or with sudo/gksudo, or alternatively set up a "normal" user to administer cups (if so '''follow steps 1-3''')
 
 
 
* 1. Create group, and add a user
 
<pre>
 
# groupadd lpadmin
 
# usermod -aG lpadmin <username>
 
</pre>
 
 
 
* 2. Add "lpadmin" (without the quotes) to this line in /etc/cups/cupsd.conf
 
<pre>
 
SystemGroup sys root <insert here>
 
</pre>
 
 
 
* 3. Restart cups, log out and in again (or restart your computer)
 
<pre>
 
# /etc/rc.d/cups restart
 
</pre>
 
 
 
[[KDE]] users can modify their printers from the Control Center.  Both should refer to those desktop environments' documentation for more information on how to use the interfaces.
 
 
 
There is also gtklp. It is in the "extra" repository.
 
 
 
<pre>
 
# pacman -S gtklp
 
</pre>
 
 
 
==PDF Virtual Printer==
 
 
 
A nice is CUPS-PDF. This package allows one to setup a virtual printer that will generate a PDF from anything sent to it. Obviously this package is not necessary, but it can be quite useful.
 
 
 
You can find generated PDF documents in a directory of your user name located in <code>/var/spool/cups-pdf</code> directory.
 
 
 
This package can be installed by the following command:
 
 
 
<pre>
 
# pacman -S cups-pdf
 
</pre>
 
 
 
After installing the package, you can set it up as you would for any other printer in the web interface.  For the Device, select '''CUPS-PDF (Virtual PDF Printer)'''; Make/Manufacturer, choose '''Generic'''; Model/Driver, select '''Generic postscript color printer'''.  Alternatively, provide the PPD file from this link: [http://www.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/cups-pdf-CURRENT/extra/CUPS-PDF.ppd].
 
 
 
==Online Resources==
 
 
 
Here is a listing of web sites that may be of use to you:
 
 
 
* <b>Official CUPS documentation on your computer</b> http://localhost:631/documentation.html
 
* <b>Official CUPS Website</b> - http://www.cups.org/
 
* <b>Linux Printing</b> - http://www.linuxprinting.org/
 
* <b>Tips and Suggestions on common CUPS problems</b> - http://home.nyc.rr.com/computertaijutsu/cups.html
 
* <b>Gentoo's Printing Guide</b> - http://www.gentoo.org/doc/en/printing-howto.xml
 
* <b>Arch Linux User Forums</b> - http://bbs.archlinux.org/
 
 
 
==Specialized Cases==
 
 
 
This section is dedicated to specific problems and their solutions. If you managed to get some unusual printer working, please put the solution here.
 
 
 
===Brother DCP 7020 ===
 
See [[Brother_DCP-7020]].
 
 
 
===Getting FX C1110 (not model B) to work ===
 
 
 
'''Assumes:'''
 
 
 
# The printer is connected and listening on the network.
 
# The printer driver is in rpm package.
 
 
 
* Install cpio and rpmunpack to later unpack rpm package
 
 
 
pacman -S cpio rpmunpack cups ghostscript gsfonts
 
 
 
* Get the FX Linux Driver [http://www.fujixeroxprinters.com/downloads/uploaded/Drivers/DocuPrint%20C1110%20C1110B/linux/fxlinuxprint-1.0.1-1.i386.zip here]
 
 
 
* In /var/tmp unzip fxlinuxprint-1.0.1-1.i386.zip
 
 
 
unzip fxlinuxprint-1.0.1-1.i386.zip -d /var/tmp
 
 
 
* In /var/tmp
 
 
 
cd /var/tmp
 
rpmunpack fxlinuxprint-1.0.1-1.i386.rpm
 
gunzip fxlinuxprint-1.0.1-1.cpio.gz
 
mkdir /var/tmp/DST
 
mv fxlinuxprint-1.0.1-1.cpio /var/tmp/DST
 
cd /var/tmp/DST
 
cpio -id < fxlinuxprint-1.0.1-1.cpio
 
rm fxlinuxprint-1.0.1-1.cpio
 
cd /var/tmp
 
find /var/tmp/DST -type f |cat -n
 
    1 /var/tmp/DST/etc/cups/mimefx.convs
 
    2 /var/tmp/DST/etc/cups/mimefx.types
 
    3 /var/tmp/DST/usr/lib/cups/filter/pdftopjlfx
 
    4 /var/tmp/DST/usr/lib/cups/filter/pstopdffx
 
    5 /var/tmp/DST/usr/lib/cups/filter/pdftopdffx
 
    6 /var/tmp/DST/usr/share/cups/model/FujiXerox/en/fxlinuxprint.ppd
 
 
 
* Copy /var/tmp/DST files to /
 
 
 
'''Note:''' for the PPD use /usr/share/cups/model/fxlinuxprint.ppd
 
 
 
* Point web browser at http://localhost:631/ and point and click to add lpd://f.q.d.n/queue printer
 
 
 
'''Note:''' in the final step authenticate using the root password
 
 
 
* Manage Printer and Set Printer Options
 
 
 
* Print a test page, and if printer name is color103, use at a shell prompt
 
 
 
lpq -Pcolor103
 
color103 is ready
 
no entries
 
 
 
* The End
 
 
 
===Printing does not work/aborts with the HP Deskjet 700 Series Printers.===
 
 
 
*The solution is to install <b>pnm2ppa</b> printer filter for the HP Deskjet 700 series. Without this the print jobs will be aborted by the system.  A [[ABS - The Arch Build System | PKGBUILD]] for pnm2ppa can be found in [http://aur.archlinux.org/packages.php?do_Details=1&ID=696&O=0&L=0&C=0&K=pnm&SB=n&SO=a&PP=25&do_MyPackages=0&do_Orphans=0 AUR].
 
 
 
===Getting HP LaserJet 1010 to work===
 
I had to compile ghostscript myself because ESP gs in rep was 7.07 and had not fixed some bugs like ESP 8.15.1 had. I never downloaded 'foomatic' in rep. I think that is an old package.
 
<pre>
 
$ pacman -Qs cups a2ps psutils foo ghost
 
local/cups 1.1.23-3
 
    The CUPS Printing System
 
local/a2ps 4.13b-3
 
    a2ps is an Any to PostScript filter
 
local/psutils p17-3
 
    A set of postscript utilities.
 
local/foomatic-db 3.0.2-1
 
    Foomatic is a system for using free software printer drivers with common
 
    spoolers on Unix
 
local/foomatic-db-engine 3.0.2-1
 
    Foomatic is a system for using free software printer drivers with common
 
    spoolers on Unix
 
local/foomatic-db-ppd 3.0.2-1
 
    Foomatic is a system for using free software printer drivers with common
 
    spoolers on Unix
 
local/foomatic-filters 3.0.2-1
 
    Foomatic is a system for using free software printer drivers with common
 
    spoolers on Unix
 
local/espgs 8.15.1-1
 
    ESP Ghostscript
 
</pre>
 
I also had to set LogLevel in <code>/etc/cups/cupsd.conf</code> to debug2 before i saw that I missed some "Nimbus" fonts. Then I had to rename and put them where the log told me to. Some fancy google searching had to be applied, e.g., http://www.google.com/search?q=n019003l+filetype%3Apfb since the fonts turned out to be proprietary (I'm sure Windows comes with these by default).  Nevertheless, after downloading them (about 7 fonts) and putting them in the correct directory, printing started working.
 
 
 
Before, I was getting all the errors said here: http://linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_1010 'Unsupport PCL' etc...
 
 
 
I'm sure it could have worked with ESP gs 7.07 too (in rep) if I were smart enough to turn on DebugLevel2 sooner :/ UPDATE: yeah it did... maybe this info is useful for someone else though... sorry for the inconvenience.
 
 
 
===Getting HP LaserJet 1020 to work===
 
 
 
====Manual installation====
 
After a lot of tries with hplib and gutenprint, I finally found the solution to get my printer HP LaserJet 1020 printing.
 
 
 
First of all, you only need to install cups and ghostscript. Then follow the link on http://www.linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_1020 to the http://foo2zjs.rkkda.com/ printer driver page and follow the install instructions. Log in as root. After you've downloaded the package and extracted the archive, change into the foo2zjs directory. Now you can follow the original installation instructions with a minor modification to change the userid for printing:
 
 
 
$ make
 
$ ./getweb 1020
 
 
Open the ''Makefile''
 
$ nano Makefile
 
and search for the line
 
# LPuid=-olp
 
and modify it to
 
# LPuid=-oroot
 
then continue with the script
 
$ make install
 
$ make install-hotplug
 
$ make cups
 
 
 
====Installation from AUR====
 
You can also use the package foo2zjs from AUR and modify the PKGBUILD. Change the line:
 
 
 
./getweb all
 
 
 
to
 
 
 
./getweb 1020
 
 
 
(or if you're setting another printer, change this line to what you need).
 
 
 
If you get errors with incorrect md5sums, you should also change the md5sum of foo2zjs.tar.gz in PKGBUILD to match the downloaded driver.
 
 
 
As a last step, add and configure the printer in the CUPS manager. The printer should be recognized automatically. It works fine for root and all users. When booting the operating system, the printer is initialized and indicates it's working.
 
 
 
=== Printer connected to an Airport Express Station ===
 
The first thing to do is to scan the airport express station. It
 
seems that there are different addresses depending on the model.
 
<pre>
 
[root@somostation somos]# nmap 192.168.0.4
 
 
 
Starting Nmap 4.20 ( http://insecure.org ) at 2007-06-26 00:50 CEST
 
Interesting ports on 192.168.0.4:
 
Not shown: 1694 closed ports
 
PORT      STATE SERVICE
 
5000/tcp  open  UPnP
 
9100/tcp  open  jetdirect
 
10000/tcp open  snet-sensor-mgmt
 
MAC Address: 00:14:51:70:D5:66 (Apple Computer)
 
 
 
Nmap finished: 1 IP address (1 host up) scanned in 25.815 seconds
 
</pre>
 
With my station, the port is 9100. The airport station is accessed like
 
an HP JetDirect printer.
 
Afterwards, you can edit your <code>printer.conf</code> file in this way:
 
<pre>
 
# Printer configuration file for CUPS v1.2.11
 
# Written by cupsd on 2007-06-26 00:44
 
<Printer LaserSim>
 
Info SAMSUNG ML-1510 gdi
 
Location SomoStation
 
DeviceURI socket://192.168.0.4:9100
 
State Idle
 
StateTime 1182811465
 
Accepting Yes
 
Shared Yes
 
JobSheets none none
 
QuotaPeriod 0
 
PageLimit 0
 
KLimit 0
 
OpPolicy default
 
ErrorPolicy stop-printer
 
</Printer>
 
</pre>
 
It should work. I had a few problems. They were resolved by removing foomatic and installing foomatic-db, foomatic-db-engine, foomatic-db-ppd instead.
 
 
 
===Performing Utility Functions on Epson Printers===
 
 
 
====Escputil====
 
 
 
Here we explain how to perform some of the utility functions such as nozzle cleaning and nozzle checks on Epson printers. We will use the escputil utility, which is part of the gutenprint package.
 
 
 
There is a man page ("man escputil") that provides pretty good information, but it does not include necessary information on how to identify your printer. There are two parameters that can be used. One is --printer; what it expects is the name you used to identify your printer when you configured it. The other is --raw-device. What this option expects is is something beginning with "/dev". If your printer is a serial printer, and the only serial printer, it is "/dev/lp0". If it is a USB printer, it is "/dev/usb/lp0". If you have more than one printer, they will have names ending in "lp1", "lp2", etc.
 
 
 
* To clean the printer heads:
 
 
 
  escputil -u --clean-head
 
 
 
* To print the nozzle-check pattern, allowing you to verify that the previous head cleaning worked. (Or to determine that you need to clean the heads)
 
 
 
  escputil -u --nozzle-check
 
 
 
If you want to perform an operation that requires two-way communication with a printer, you must use the "--raw-device" specification and your user must be root or be a member of the group "lp".
 
 
 
* The following is an example of getting the printer's internal identification:
 
 
 
  sudo escputil --raw-device=/dev/usb/lp0 --identify
 
 
 
* To print out the ink levels of the printer:
 
 
 
  sudo escputil --raw-device=/dev/usb/lp0 --ink-level
 
  
====Mtink====
+
By default, all logs are sent to files in {{ic|/var/log/cups/}}. By changing the values of the {{ic|AccessLog}}, {{ic|ErrorLog}}, and {{ic|PageLog}} directives in {{ic|/etc/cups/cups-files.conf}} to {{ic|syslog}}, CUPS can be made to log to the [[systemd journal]] instead. See [https://fedoraproject.org/wiki/Changes/CupsJournalLogging the fedora wiki page] for information on the original proposed change.
  
This is a printer status monitor which enables to get the remaining ink quantity, to print test patterns, to reset printer and to clean nozzle. It use an intuitive graphical user interface. Package can be downloaded from [http://aur.archlinux.org/packages.php?do_Details=1&ID=476&O=0&L=0&C=0&K=mtink&SB=n&SO=a&PP=25&do_MyPackages=0&do_Orphans=0&SeB=nd AUR].
+
=== cups-browsed ===
  
==Another Source for Printer Drivers==
+
{{Out of date|{{ic|cups-browsed.service}} is not required to discover printers advertised over DNS-SD, that is done by {{ic|org.cups.cupsd.service}}. The service is only required to discover printers on an LDAP server and those using the legacy CUPS protocol (CUPS servers ≤ 1.5).}}
  
On <i>http://www.turboprint.de/english.html</i> is a really good printer driver for many printers not yet supported by Linux (especially Canon i*). The only problem is that high-quality-prints are either marked with a turboprint-logo or you have to pay for it -- it's not open source.
+
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, set up [[Avahi#Hostname_resolution|.local hostname resolution]], and start both {{ic|avahi-daemon.service}} and {{ic|cups-browsed.service}}. Jobs are sent directly to the printer without any processing so the created queues may not work, however driverless printers such as those supporting [http://www.pwg.org/ipp/everywhere.html IPP Everywhere] or [[wikipedia:AirPrint|AirPrint]] should work out of the box.
  
{{Wikipedia|Common_Unix_Printing_System}}
+
{{Note|1=<nowiki></nowiki>
 +
* Searching for network printers [https://bbs.archlinux.org/viewtopic.php?pid=1720219#p1720219 may significantly increase the time it takes for your computer to boot].
 +
* {{ic|cups-browsed.service}} is only needed to dynamically add and remove printers as they appear and disappear from a network. It is not required if you simply want to add a an DNS-SD/mDNS supporting network printer to CUPS.
 +
}}
  
=Troubleshooting=
+
=== Print servers and remote administration ===
==As a result of upgrade==
 
  
===Error with gnutls===
+
See [[CUPS/Printer sharing]] and [[CUPS/Printer sharing#Remote administration]].
After updating, if you get something like :
 
  /usr/sbin/cupsd: error while loading shared libraries: libgnutls.so.13: cannot open shared object file: No such file or directory
 
  
You need to update gnutls:
+
=== Allowing admin authentication through PolicyKit ===
<pre>
 
# pacman -Sy gnutls
 
</pre>
 
  
In addition, in <code>/etc/cups</code>, there will be a file named <code>cupsd.conf.pacnew</code>.  Rename it <code>cupsd.conf</code>.
+
[[PolicyKit]] can be configured to allow users to configure printers using a GUI without the admin password.
  
===All jobs are "stopped"===
+
{{Note|1=You may need to install {{Pkg|cups-pk-helper}} for working this rules.}}
After updating CUPS, if all jobs sent to the printer become "stopped", delete the printer and add it again.
 
Using the CUPS web interface (http://localhost:631), go to Printers > Delete Printer.
 
  
''Note:'' If you don't remember your printer's settings, go to Printers > Modify Printer. Copy down the information displayed, click 'Modify Printer' to proceed to the next page(s), etc.
+
Here is an example that allows members of the wheel [[user group]] to administer printers without a password:
  
===The PPD version (XXXXXX) is not compatible with Gutenprint X===
+
{{hc|/etc/polkit-1/rules.d/49-allow-passwordless-printer-admin.rules|<nowiki>
Run (as root)
+
polkit.addRule(function(action, subject) {
<pre>
+
    if (action.id == "org.opensuse.cupspkhelper.mechanism.all-edit" &&
/usr/sbin/cups-genppdupdate
+
        subject.isInGroup("wheel")){
</pre>
+
        return polkit.Result.YES;
And restart CUPS (as pointed out in gutenprint's post-install message)
+
    }
 +
});
 +
</nowiki>}}
  
==Other==
+
=== Without a local CUPS server ===
  
===A HPLIP printer sends "/usr/lib/cups/backend/hp failed" error===
+
CUPS can be configured to directly connect to remote printer servers instead of running a local print server. This requires [[install]]ation of the {{Pkg|libcups}} package. Some applications will still require the {{Pkg|cups}} package for printing.
Make sure dbus is installed and running, e.g. check DAEMONS in /etc/rc.conf or run 'ls /var/run/daemons'.
 
  
===CUPS returns ""foomatic-rip" not available/stopped with status 3" with a HP printer===
+
{{Warning|Accessing remote printers without a local CUPS server is not recommended by the developers. [https://lists.cups.org/pipermail/cups/2015-October/027229.html]}}
  
If you receive any of the following error messages in /var/log/cups/error_log while using a HP printer, with jobs appearing to be processed while they all end up not being completed with their status set to 'stopped':
+
To use a remote CUPS server, set the {{ic|CUPS_SERVER}} [[environment variable]] to {{ic|printerserver.mydomain:port}}. For instance, if you want to use a different print server for a single [[Firefox]] instance (substitute {{ic|printserver.mydomain:port}} with your print server name/port):
  
* Filter "foomatic-rip" for printer "<printer_name>" not available: No such file or director
+
$ CUPS_SERVER=printserver.mydomain:port firefox
* PID 5771 (/usr/lib/cups/filter/foomatic-rip) stopped with status 3!
 
  
Make sure you have  '''hplip''' installed, in addition to [[CUPS_Setup#Packages|the packages mentioned above]]; '''net-snmp''' is also needed. See http://bbs.archlinux.org/viewtopic.php?id=65615
+
== Troubleshooting ==
  
<pre>
+
See [[CUPS/Troubleshooting]].
# pacman -S hplip
 
</pre>
 
  
Personally I experienced this with a HP LaserJet 1100A (hplip says it only supports a couple of laser models, which could make you skip the option of trying it) over an LPR print server. I don't know if it applies to using it through /dev/lp0 (parallell port) as well, although it would make sense.
+
== See also ==
  
===Printing fails with unauthorised error===
+
* [http://localhost:631/help Official CUPS documentation], ''locally installed''
If you added yourself to the lp group, and allowed your user to print (cups.conf), then problem lies in /etc/cups/printers.conf. There should be a line that says
+
* [[Wikipedia:CUPS]]
<pre>AuthInfoRequired negotiate</pre>
+
* [http://www.linuxfoundation.org/collaborate/workgroups/openprinting OpenPrinting homepage]
Just delete it or comment it out, restart cups and printing will magically work again.
+
* [https://en.opensuse.org/Concepts_printing OpenSuSE Concepts printing guide - explains the full printing workflow]
 +
* [https://en.opensuse.org/SDB:CUPS_in_a_Nutshell OpenSuSE CUPS in a Nutshell - a quick CUPS overview]
 +
* [https://wiki.gentoo.org/wiki/Printing Gentoo's printing guide]
 +
* [[debian:Printing|Debian's Printing portal - detailed technical guides]]
 +
* [[debian:SystemPrinting|Debian's printing overview - a basic view of the CUPS printing system]]

Latest revision as of 13:24, 22 January 2020

CUPS is the standards-based, open source printing system developed by Apple Inc. for macOS® and other UNIX®-like operating systems.

Installation

Install the cups 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/username/. The location can be changed in /etc/cups/cups-pdf.conf.

Enable and start org.cups.cupsd.service.

Socket activation

cups provides a org.cups.cupsd.socket unit. If org.cups.cupsd.socket is enabled (and org.cups.cupsd.service is disabled), systemd will not start CUPS immediately, it will just listen to the appropriate sockets. Then, whenever a program attempts to connect to one of these CUPS sockets, systemd will start org.cups.cupsd.service and transparently hand over control of these ports to the CUPS process.

This way, CUPS is only started once a program wants to make use of the service.

Connection Interfaces

Additional steps for printer detection are listed below for various connection interfaces.

Note:
  • CUPS helper programs are run using the cups user and group. This allows the helper programs to access printer devices and read config files in /etc/cups/, which are owned by the cups group.
  • Prior to cups 2.2.6-2, the lp group was used instead. After the upgrade, the files in /etc/cups should be owned by the cups group and User 209 and Group 209 set in /etc/cups/cups-files.conf.

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 parport
 parport0: Printer, Hewlett-Packard HP LaserJet 2100 Series
 lp0: using parport0 (polling)

Network

To discover or share printers using DNS-SD/mDNS, setup .local hostname resolution with Avahi and restart org.cups.cupsd.service.

Note: DNS-SD is only supported when using Avahi. CUPS does not support using systemd-resolved for DNS-SD, see CUPS issue 5452.

To share printers with Samba, e.g. if the system is to be a print server for Windows clients, the samba package will be required.

Printer Drivers

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: CUPS is planning to drop PPD and driver support (CUPS issue 5271), instead relying entirely on IPP Everywhere. Explain what is/will be handled by cups and what by cups-filters and/or other software. (Discuss in Talk:CUPS#CUPS printer drivers and backends are deprecated)


The drivers for a printer may come from any of the sources shown below. See CUPS/Printer-specific problems for an incomplete list of drivers that others have managed to get working.

To drive a printer, CUPS needs a PPD file and, for most printers, some filters. For details on how CUPS uses PPDs and filters, see [1].

The OpenPrinting Printer List provides driver recommendations for many printers. It also supplies PPD files for each printer, but most are available through foomatic or the recommended driver package.

When a PPD file is provided to CUPS, the CUPS server will regenerate the PPD files and save them in /etc/cups/ppd/.

CUPS

CUPS includes support for AirPrint and IPP Everywhere printers.

OpenPrinting CUPS filters

The Linux Foundation's OpenPrinting workgroup provides cups-filters. Those are backends, filters, and other binaries that were once part of CUPS but are no longer maintained by Apple. They are available in the cups-filters package that is a dependency of cups.

Non-PDF printers require ghostscript to be installed. For PostScript printers gsfonts may also be required.

Foomatic

The Linux Foundation's OpenPrinting workgroup's foomatic provides PPDs for many printer drivers, both free and nonfree. For more information about what foomatic does, see Foomatic from the Developer's View.

To use foomatic, install foomatic-db-engine and at least one of:

The foomatic PPDs may require additional filters, such as min12xxwAUR.

Gutenprint

The Gutenprint project provides drivers for Canon, Epson, Lexmark, Sony, Olympus, and PCL printers for use with CUPS and GIMP.

Install gutenprint and foomatic-db-gutenprint-ppds.

Note: When the Gutenprint packages get updated, the printers using Gutenprint drivers will stop working until you run cups-genppdupdate as root and restart CUPS. cups-genppdupdate will update the PPD files of the configured printers, see cups-genppdupdate(8) for more details.

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.

Printer URI

Listed below are additional steps to manually generate the URI if required. Some printers or drivers may need a special URI as described in CUPS/Printer-specific problems.

USB

CUPS should be able to automatically generate a URI for USB printers, for example usb://HP/DESKJET%20940C?serial=CN16E6C364BH.

If it does not, see CUPS/Troubleshooting#USB printers for troubleshooting steps.

Parallel port

The URI should be of the form parallel:device. For instance, if the printer is connected on /dev/lp0, use parallel:/dev/lp0. If you are using a USB to parallel port adapter, use parallel:/dev/usb/lp0 as the printer URI.

Network

If you have set up Avahi as in #Network, CUPS should detect the printer URI. You can also use avahi-discover to find the name of your printer and its address (for instance, BRN30055C6B4C7A.local/10.10.0.155:631).

The URI can also be generated manually, without using Avahi. A list of the available URI schemes for networked printers is available in the CUPS documentation. As exact details of the URIs differ between printers, check either the manual of the printer or CUPS/Printer-specific problems.

The URI for printers on SMB shares is described in the smbspool(8) man page.

Note: Any special characters in the printer URIs need to be appropriately quoted, or, if your Windows printer name or user passwords have spaces, CUPS will throw a lpadmin: Bad device-uri error.

For example, smb://BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6 becomes smb://BEN-DESKTOP/HP%20Color%20LaserJet%20CP1510%20series%20PCL6.

This result string can be obtained by running the following command:

$ python -c 'from urllib.parse import quote; print("smb://" + quote("BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6"))'

Remote CUPS print servers can be accessed through a URI of the form ipp://hostname:631/printers/queue_name. See CUPS/Printer sharing#Printer sharing for details on setting up the remote print server.

See CUPS/Troubleshooting#Networking issues for additional issues and solutions.

Warning: Avoid configuring both the server and the client with a printer filter - either the print queue on the client or the server should be 'raw'. This avoids sending a print job through the filters for a printer twice, which can cause problems (for instance, [2]). See #Usage for an example of setting a print queue to 'raw'.

Usage

CUPS can be fully controlled using the lp* and cups* CLI tools. Alternatively, the #Web interface or one of several #GUI applications can be used.

  • The queue name is a short but descriptive name used on the system to identify the queue. This name should not contain spaces or any special characters. For instance, a print queue corresponding to a HP LaserJet 5P could be named "hpljet5p". More than one queue can be associated with each physical printer.
  • The location is a description of the printer's physical location (for instance "bedroom", or "kitchen"). This is to aid in maintaining several printers.
  • The description is a full description of the print queue. A common use is a full printer name (like "HP LaserJet 5P").

CLI tools

See CUPS local documentation for more tips on the command-line tools.

Note: Command-line switches cannot be grouped

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: Nonstandard use of definition lists, comments in command line. (Discuss in Talk:CUPS#)
List the devices
# lpinfo -v
$ /usr/lib/cups/backend/snmp ip_address  # Use SNMP to find a URI
List the models
$ lpinfo -m
Add a new queue
# lpadmin -p queue_name -E -v uri -m model

The queue_name is up to you. Examples:

# lpadmin -p HP_DESKJET_940C -E -v "usb://HP/DESKJET%20940C?serial=CN16E6C364BH" -m drv:///HP/hp-deskjet_940c.ppd.gz
# lpadmin -p AirPrint -E -v "ipp://10.0.1.25/ipp/print" -m everywhere    # Driverless queue (Apple AirPrint or IPP Everywhere)
# lpadmin -p SHARED_PRINTER -m raw    # Raw queue; no PPD or filter
# lpadmin -p Test_Printer -E -v "ipp://10.0.1.3/ipp/print" -m pxlmono.ppd    # Specifying a PPD instead of a model
Note: When specifying the PPD, use just the file name and not the full path (for instance, pxlmono.ppd instead of /usr/share/ppd/cupsfilters/pxlmono.ppd). Alternatively, the full path can be used with the -P command line switch.
Set the default printer
$ lpoptions -d queue_name
Change the options
$ lpoptions -p queue_name -l # List the options
$ lpoptions -p queue_name -o option=value # Set an option

Example:

$ lpoptions -p HP_DESKJET_940C -o PageSize=A4
Check the status
$ lpstat -s
$ lpstat -p queue_name
Deactivate a printer
# cupsdisable queue_name
Activate a printer
# cupsenable queue_name
Set the printer to accept jobs
# cupsaccept queue_name
Remove a printer

First set it to reject all incoming entries:

# cupsreject queue_name

Then disable it.

# cupsdisable queue_name

Finally remove it.

# lpadmin -x queue_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 queue
$ lpq
$ lpq -a # on all queues
Clear the queue
# lprm   # remove last entry only
# lprm - # remove all entries
View ink levels

Install inkAUR.

Add your user to the lp user group:

# usermod -aG lp <user>

Log out and log in again.

For usage information, use:

$ ink

Web interface

The CUPS server can be fully administered through the web interface, available on http://localhost:631/.

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

To perform administrative tasks from the web interface authentication is required. Authenticate either as root or make sure your user is member of a group with printer administration privileges, see #Configuration.

Add a queue

Go to the Administration page.

Modify existing queues

Go to the Printers page, and select a queue to modify.

Test a queue

Go to the Printers page, and select a queue.

GUI applications

If your user does not have sufficient privileges to administer CUPS, the applications will request the root password when they start. To give users administrative privileges without needing root access, see #Configuration.

  • GtkLP — GTK interface for CUPS.
https://gtklp.sirtobi.com/index.shtml || gtklpAUR
  • print-manager — Tool for managing print jobs and printers (KDE).
https://cgit.kde.org/print-manager.git || print-manager
  • system-config-printer — GTK printer configuration tool and status applet.
http://cyberelk.net/tim/software/system-config-printer/ || system-config-printer

Configuration

The CUPS server configuration is located in /etc/cups/cupsd.conf and /etc/cups/cups-files.conf (see cupsd.conf(5) and cups-files.conf(5)). After editing either file, restart org.cups.cupsd.service to apply any changes. The default configuration is sufficient for most users.

User groups with printer administration privileges are defined in SystemGroup in the /etc/cups/cups-files.conf. The sys and root and wheel groups are used by default.

cups is built with libpaper support and libpaper defaults to the Letter paper size. To avoid having to change the paper size for each print queue you add, edit /etc/papersize and set your system default paper size. See papersize(5).

By default, all logs are sent to files in /var/log/cups/. By changing the values of the AccessLog, ErrorLog, and PageLog directives in /etc/cups/cups-files.conf to syslog, CUPS can be made to log to the systemd journal instead. See the fedora wiki page for information on the original proposed change.

cups-browsed

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: cups-browsed.service is not required to discover printers advertised over DNS-SD, that is done by org.cups.cupsd.service. The service is only required to discover printers on an LDAP server and those using the legacy CUPS protocol (CUPS servers ≤ 1.5). (Discuss in Talk:CUPS#)

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, set up .local hostname resolution, and start both avahi-daemon.service and cups-browsed.service. Jobs are sent directly to the printer without any processing so the created queues may not work, however driverless printers such as those supporting IPP Everywhere or AirPrint should work out of the box.

Note:

Print servers and remote administration

See CUPS/Printer sharing and CUPS/Printer sharing#Remote administration.

Allowing admin authentication through PolicyKit

PolicyKit can be configured to allow users to configure printers using a GUI without the admin password.

Note: You may need to install cups-pk-helper for working this rules.

Here is an example that allows members of the wheel user group to administer printers without a password:

/etc/polkit-1/rules.d/49-allow-passwordless-printer-admin.rules
polkit.addRule(function(action, subject) { 
    if (action.id == "org.opensuse.cupspkhelper.mechanism.all-edit" && 
        subject.isInGroup("wheel")){ 
        return polkit.Result.YES; 
    } 
});

Without a local CUPS server

CUPS can be configured to directly connect to remote printer servers instead of running a local print server. This requires installation of the libcups package. Some applications will still require the cups package for printing.

Warning: Accessing remote printers without a local CUPS server is not recommended by the developers. [3]

To use a remote CUPS server, set the CUPS_SERVER environment variable to printerserver.mydomain:port. For instance, if you want to use a different print server for a single Firefox instance (substitute printserver.mydomain:port with your print server name/port):

$ CUPS_SERVER=printserver.mydomain:port firefox

Troubleshooting

See CUPS/Troubleshooting.

See also