mirror of
https://pagure.io/fedora-docs/quick-docs.git
synced 2024-12-01 07:39:48 +00:00
322 lines
13 KiB
Text
322 lines
13 KiB
Text
[id='con_cups-useful-tricks']
|
|
= Useful tricks
|
|
|
|
== How to find out whether my printer is capable of driverless printing?
|
|
|
|
Network printers have the prerequisites - enablement of IPP port on the printer is the minimum, mDNS is required for automatic printer discovery by `libcups`.
|
|
|
|
* [command]`ipptool` command which sends IPP Get-Printer-Attributes request to the network printer passes:
|
|
|
|
----
|
|
$ ipptool -tv ipp://printer.example.com:631/ipp/print get-printer-attributes.test
|
|
"/usr/share/cups/ipptool/get-printer-attributes.test":
|
|
Get-Printer-Attributes:
|
|
attributes-charset (charset) = utf-8
|
|
attributes-natural-language (naturalLanguage) = en
|
|
printer-uri (uri) = ipp://printer.example.com:631/ipp/print
|
|
requested-attributes (1setOf keyword) = all,media-col-database
|
|
Get printer attributes using get-printer-attributes [PASS]
|
|
...
|
|
----
|
|
|
|
, where `printer.example.com` is the hostname or IP of your network printer,
|
|
|
|
* look for AirPrint among device specification,
|
|
* https://www.pwg.org/printers/[Officially certified printers for IPP Everywhere],
|
|
* check xref:_how_to_setup_cups_temporary_queues_with_network_printer[manual] for enabling CUPS temporary queues - if your printer is seen in the end in CUPS commands that way, your printer is capable of driverless printing,
|
|
* [USB devices only] check for IPP over USB (xref:_how_to_find_out_if_my_usb_device_supports_ipp_over_usb[manual] here).
|
|
|
|
== How to find out my multifunction device or standalone scanner is capable of driverless scanning?
|
|
|
|
* check the device specification and look for eSCL/AirScan/WSD - if any of these are mentioned, the device is capable of driverless scanning
|
|
* most devices which advertise they can do AirPrint are capable of AirScan too
|
|
* [USB devices only] check for IPP over USB (xref:_how_to_find_out_if_my_usb_device_supports_ipp_over_usb[manual] here).
|
|
|
|
== How to find out if my USB device supports IPP over USB
|
|
|
|
Check whether your USB device has a following text in [command]`lsusb -v` output:
|
|
|
|
----
|
|
...
|
|
bInterfaceClass 7 Printer
|
|
bInterfaceSubClass 1 Printer
|
|
bInterfaceProtocol 4
|
|
iInterface 0
|
|
...
|
|
----
|
|
|
|
If the device has the _bInterfaceClass 7_, _bInterfaceSubClass 1_ and _bInterfaceProtocol 4_ in the sequence, it supports IPP over USB which is critical for USB device driverless printing and scanning.
|
|
|
|
== How to install a print queue
|
|
|
|
The answer is you don't have to install at all :) if your device is new enough, is in your local network or is an USB device, has IPP/AirPrint/mDNS enabled and your *avahi-daemon* is running, CUPS is able to create a temporary queue for you right away in the print dialog, print via it and remove it after successful printing. But there are still use cases when permanent installation is needed like sharing a print queue, different print queue defaults or printer being in different subnet, so I will cover a permanent instalation too.
|
|
|
|
=== How to setup CUPS temporary queues with network printer
|
|
|
|
If your printer is capable of AirPrint, IPP and MDNS is enabled in your printer and printer is in your local network, then to get CUPS temporary queues working you need:
|
|
|
|
* have *avahi-daemon* running:
|
|
|
|
----
|
|
$ sudo systemctl start avahi-daemon
|
|
----
|
|
|
|
* have *cups.socket* enabled and running running:
|
|
|
|
----
|
|
$ sudo systemctl enable cups.socket
|
|
$ sudo systemctl start cups.socket
|
|
----
|
|
|
|
* enable MDNS in your firewall settings
|
|
|
|
After this the temporary queue will appear in the print dialog and you don't need to install a specific print queue unless you have a reason for it.
|
|
|
|
You can check if your printer is seen in mDNS messages by (*avahi-tools* must be installed):
|
|
|
|
----
|
|
$ avahi-browse -avrt
|
|
...
|
|
= enp0s25 IPv4 HP LaserJet M1536dnf MFP (42307C) _ipp._tcp local
|
|
hostname = [NPI42307C.local]
|
|
address = [192.168.1.10]
|
|
port = [631]
|
|
txt = ["UUID=434e4239-4243-4a42-5859-3c4a9242307c" "Scan=T" "Duplex=T" "Color=F" "note=" "adminurl=http://NPI42307C.local." "priority=10" "product=(HP LaserJet M1536dnf MFP)" "ty=HP LaserJet M1536dnf MFP" "URF=CP99,W8,OB10,PQ3-4-5,DM1,IS1-4,MT1-2-3-5,MT1-2-3-5,RS600" "rp=ipp/printer" "pdl=application/postscript,application/vnd.hp-PCL,application/vnd.hp-PCLXL,application/pdf,image/urf" "qtotal=1" "txtvers=1"]
|
|
...
|
|
----
|
|
|
|
and if CUPS or its backends see the printer by commands:
|
|
|
|
(lists all existing print queues - permanent or temporary)
|
|
|
|
----
|
|
$ lpstat -e
|
|
HP_LaserJet_M1536dnf_MFP_42307C_
|
|
----
|
|
|
|
or
|
|
|
|
(lists all devices, which CUPS sees in the local network or USB)
|
|
|
|
----
|
|
$ lpinfo -l -v
|
|
...
|
|
Device: uri = ipp://HP%20LaserJet%20M1536dnf%20MFP%20(42307C)._ipp._tcp.local/
|
|
class = network
|
|
info = HP LaserJet M1536dnf MFP (driverless)
|
|
make-and-model = HP LaserJet M1536dnf MFP
|
|
device-id = MFG:HP;MDL:LaserJet M1536dnf MFP;CMD:PDF,PS,PCL,AppleRaster,URF;
|
|
location =
|
|
...
|
|
----
|
|
|
|
=== How to setup CUPS temporary queues with USB printer
|
|
|
|
USB printers have only one additional prerequisite, installing *ipp-usb*, which will transform IPP over USB devices to network printer on localhost:
|
|
|
|
----
|
|
$ sudo dnf -y install ipp-usb
|
|
----
|
|
|
|
Then you can follow the steps in xref:_how_to_setup_cups_temporary_queues_with_network_printer[manual] for network printers.
|
|
|
|
=== How to install a permanent print queue
|
|
|
|
Prerequisties for permanent driverless printers: enable IPP in your firewall, enable IPP on your printer if possible.
|
|
|
|
==== Installation via CUPS web UI ====
|
|
|
|
* start cups.service
|
|
|
|
----
|
|
$ sudo systemctl start cups
|
|
----
|
|
|
|
* go to *Administration* tab
|
|
* click on *Add printer*
|
|
* enter your credentials
|
|
* choose the found device or the connection you prefer - for driverless permanent queue choose *Internet Printing Protocol (ipp)*
|
|
* in case you didn't choose a found device, enter the device uri at the next page - for driverless printers they usually are:
|
|
|
|
----
|
|
Network printers:
|
|
ipp://<printer_IP_or_printer_hostname>:631/ipp/print
|
|
|
|
USB printers via ipp-usb:
|
|
ipp://localhost:60000/ipp/print
|
|
|
|
Non-driverless printers via printer application:
|
|
ipp://localhost:8000/ipp/print/<printer_name>
|
|
|
|
Printers pointing to a remote CUPS server:
|
|
ipp://<server_ip_or_server_hostname>:631/printers/<remote_print_queue>
|
|
----
|
|
|
|
* choose device manufacturer and model (*IPP Everywhere* for driverless printers)
|
|
* set a different default options if needed and finish
|
|
|
|
*Notes:*
|
|
|
|
Adding a permanent queue for driverless USB printers or non-driverless printers installed in a printer application is usually unnecessary, because they are shared by mDNS on localhost, so any application using CUPS 2.0+ API functions (cupsGetDests(), cupsGetNamedDest(), cupsCopyDestInfo()) should be able to pick them automatically (for network printer it depends whether the device is in the same subnet as your machine). Installling them permanently should be necessary only if an application doesn't use the recent API or to work around a bug which happens when using them as temporary queues.
|
|
|
|
If there are more devices via *ipp-usb* or printer applications, they listen on different ports - devices via ipp-usb start on port 60000, separate printer applications start on port 8000.
|
|
|
|
|
|
==== Installation via CLI commands ====
|
|
|
|
* you will need a device uri - `<device_uri>`, which you can find by `lpinfo -v`:
|
|
|
|
----
|
|
$ lpinfo -v
|
|
direct usb://HP/Officejet%20Pro%208500%20A909a?serial=NNNNNNNNN&interface=1
|
|
====================================================================
|
|
network dnssd://Officejet%20Pro%208500%20A909a%20%5B43FD8E%5D._pdl-datastream._tcp.local/
|
|
=================================================================================
|
|
----
|
|
|
|
or construct it manually - f.e. for IPP printers:
|
|
|
|
----
|
|
ipp://<IP/hostname>:631/ipp/print
|
|
----
|
|
|
|
and a driver name - `<driver>`, f.e.:
|
|
|
|
----
|
|
$ lpinfo -m
|
|
....
|
|
everywhere IPP Everywhere
|
|
==========
|
|
...
|
|
----
|
|
|
|
----
|
|
$ lpadmin -p <name> -v <device_uri> -m <driver> -E
|
|
----
|
|
|
|
where `<device_uri>` and `<driver>` are underscored strings from previous commands and `<name>` is a print queue name, which is chosen by you.
|
|
|
|
== How to install a printer via printer application in SNAP and making it available for CUPS
|
|
|
|
Currently printer applications are available in SNAPs on Fedora. I'm planning to release them as RPMs, but the code base will be the same, so its testing can happen even with SNAPs.
|
|
|
|
* install snapd,
|
|
|
|
First we have to install snapd for testing purposes:
|
|
|
|
----
|
|
$ sudo dnf -y install snapd
|
|
$ sudo ln -s /var/lib/snapd/snap /snap
|
|
$ snap version
|
|
----
|
|
|
|
If the installation had been successful, the last command will show snapd's version.
|
|
|
|
* install and run printer application,
|
|
|
|
First the SNAP with printer application has to be installed and started by the commands below. All printer applications are available in SNAP Store under the same names as they are at https://github.com/orgs/OpenPrinting/repositories[OpenPrinting repositories]. We will use [filename]`ps-printer-app` printer application in the next steps.
|
|
|
|
----
|
|
$ sudo snapd install --edge ps-printer-app
|
|
$ sudo snapd run ps-printer-app
|
|
----
|
|
|
|
* go to http://localhost:8000,
|
|
|
|
After starting the printer application its web interface becomes available at http://localhost:8000 - if user installs and runs another printer application, it will become available at localhost on the next port (8001). The printer application can contain several printers (as [filename]`cupsd` does).
|
|
|
|
* click on `Add Printer` on the main page,
|
|
* choose the printer's name,
|
|
* select the found device or choose `Network printer` from `Device` scroll menu and provide hostname or IP of the device,
|
|
* choose to auto-detect driver or select the driver by yourself,
|
|
* click on `Add Printer`,
|
|
* now the printer should be available at least on localhost via mDNS (if [filename]`avahi-daemon` is running and `nss-mdns` is installed)- check it by [filename]`avahi-browse`(`avahi-tools` has to be installed):
|
|
|
|
----
|
|
$ avahi-browse -avrt
|
|
...
|
|
= lo IPv4 HP Laserjet M1536 _ipp._tcp local
|
|
hostname = [fedora-2.local]
|
|
address = [127.0.0.1]
|
|
port = [8000]
|
|
txt = ["Scan=F" "PaperMax=legal-A4" "Fax=F" "product=(HP LaserJet M1536dnf MFP Postscript (recommended))" "mopria-certified=1.3" "priority=0" "qtotal=1" "txtvers=1" "Duplex=T" "Color=F" "TLS=1.2" "URF=V1.5,W8,PQ3-4-5,DM1,FN3,IS0-20,MT1-5-6-3,OB10,RS300-600" "UUID=24837a30-5f87-3ac9-6d85-086d486092dd" "pdl=image/pwg-raster,image/urf,application/vnd.printer-specific,application/pdf,application/postscript,image/jpeg,image/png" "note=" "adminurl=http://fedora-2.local:8000/HP_Laserjet_M1536/" "ty=HP LaserJet M1536dnf MFP Postscript (recommended)" "rp=ipp/print/HP_Laserjet_M1536"]
|
|
...
|
|
----
|
|
|
|
* and by `lpstat -e`:
|
|
|
|
----
|
|
$ lpstat -e
|
|
...
|
|
HP_Laserjet_M1536
|
|
...
|
|
----
|
|
|
|
The available printing options for the printer installed via printer application can be checked with [filename]`lpoptions` command:
|
|
|
|
----
|
|
$ lpoptions -p HP_Laserjet_M1536 -l
|
|
PageSize/Media Size: 184.15x260mm 195.09x269.88mm A4 A5 B5 DoublePostcardRotated Env10 EnvC5 EnvDL EnvMonarch Executive FanFoldGermanLegal ISOB5 Legal *Letter Postcard roc16k Custom.WIDTHxHEIGHT
|
|
InputSlot/Media Source: *Auto Tray1 Auto
|
|
MediaType/Media Type: *Unspecified Stationery Light6074 MidWeight96110 Heavy111130 ExtraHeavy131175 MonochromeLaserTransparency Labels StationeryLetterhead Envelope StationeryPreprinted Prepunched Colored Bond StationeryRecycled Rough Vellum
|
|
cupsPrintQuality/cupsPrintQuality: Draft *Normal High
|
|
ColorModel/Output Mode: *Gray
|
|
Duplex/Duplex: *None DuplexNoTumble DuplexTumble
|
|
OutputBin/OutputBin: *FaceDown
|
|
----
|
|
|
|
== How to install a scanner
|
|
|
|
Scanners in Linux don't have to be installed the same way as printers are if they are in the same network or connected via USB - you just need *sane-backends* to be installed and any scanning application will communicate with scanner/multifunction device via the backend which supports the scanner.
|
|
|
|
However, the older HP scanners and multifunction devices require an additional package - *hplip* - and its binary plugins downloaded via [command]`hp-plugin -i` if they aren't supported by sane-backends already.
|
|
|
|
=== How to make driverless scanning work
|
|
|
|
For LAN located and USB devices:
|
|
|
|
* have *avahi-daemon* enabled and running
|
|
|
|
----
|
|
$ sudo systemctl enable avahi-daemon
|
|
$ sudo systemctl start avahi-daemon
|
|
----
|
|
|
|
* enable MDNS in firewall
|
|
* [USB devices only] install *ipp-usb*
|
|
|
|
For network scanners in a different network:
|
|
|
|
* set the scanner device uri in [filename]`/etc/sane.d/airscan.conf` - see:
|
|
|
|
----
|
|
man sane-airscan
|
|
----
|
|
|
|
== How to setup mDNS with systemd-resolved
|
|
|
|
systemd-resolved is enabled and running by default since F33 and can be setup to work with Avahi on mDNS support which CUPS needs - Avahi does the advertising, registering and sharing devices, and resolved will handle '.local' address resolution. It will work with following steps:
|
|
|
|
* put [option]`MulticastDNS=resolve` into [filename]`/etc/systemd/resolved.conf`
|
|
|
|
----
|
|
$ sudo systemctl restart systemd-resolved
|
|
$ sudo nmcli connection modify <connection_name> connection.mdns yes connection.llmnr yes
|
|
$ sudo systemctl restart NetworkManager
|
|
----
|
|
|
|
== How to compress files
|
|
|
|
Example:
|
|
|
|
----
|
|
$ tar -czvf cups-information.tar.gz /etc/cups cups.logs troubleshoot.txt lpinfo.log
|
|
----
|
|
|
|
== Restarting cups service
|
|
|
|
You restart cups service with:
|
|
|
|
----
|
|
su -c 'systemctl restart cups.service'
|
|
----
|