Printer Setup: Difference between revisions
No edit summary |
Prabuanand (talk | contribs) (changed introduction paragraph and few other sentence) |
||
(12 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
[https://en.wikipedia.org/wiki/CUPS CUPS] is a modular printing system for Unix-like computer operating systems. This page explains how to install and configure printers in Alpine Linux. | |||
== Installation == | |||
{{ | Install the basic packages need for configuring printers: {{cmd|# apk add cups cups-filters}} As of now, {{pkg|cups-pdf}} package is available in the [[Repositories#Testing|testing]] repository. It can be safely installed by following the [[Repositories#Using_testing_repository|guidelines]] as per the below command:{{cmd|# apk add cups-pdf@testing}} | ||
Confirm cups starts. You may also set it to run at boot-up. | == Service configuration == | ||
{{cmd|# | |||
Confirm that cups [[OpenRC]] service starts. You may also set it to run at boot-up. | |||
{{cmd|# rc-service cupsd start}} | |||
{{cmd|# rc-update add cupsd boot}} | {{cmd|# rc-update add cupsd boot}} | ||
Go to http://localhost:631 with your web browser and follow the steps to "Add Printer". It will ask you to log in to add a printer. Log in as root, then finish the steps. Once you're done, you should be able to print. | == Printer configuration == | ||
Go to <code><nowiki>http://localhost:631</nowiki></code> with your web browser and follow the steps to "Add Printer". It will ask you to log in to add a printer. Log in as root, then finish the steps. Once you're done, you should be able to print. | |||
{{pkg|hplip}} package was available in the [[Repositories|Repositories]] repository until V3.20 to configure ''Hewlett-Packard'' (''HP'') printers. It can be safely installed as per the below command:{{ic|# apk add hplip}} | |||
If that doesn't work, you may also need to add HPLIP's dependencies separately. There are currently no packages for '''CUPS DDK''', <code>hp-setup</code> or <code>foomatic</code>. | If that doesn't work, you may also need to add HPLIP's dependencies separately. There are currently no packages for '''CUPS DDK''', <code>hp-setup</code> or <code>foomatic</code>. | ||
{{cmd|# apk add ghostscript py3-reportlab libjpeg net-snmp}} | |||
{{Expand|Modifications/sections required e.g. to address container user-case scenarios, etc.}} | {{Expand|Modifications/sections required e.g. to address container user-case scenarios, etc.}} | ||
== mdev | == Configure mdev for USB printers == | ||
By default USB printer with | By default USB printer with [[mdev]] would have ownership ''root:root'' and permission ''0660''. As ''cupsd'' would try to open a libusb-based printer as ''lp'' user, it won't have permission to use the device in ''/dev/bus/usb''. | ||
First let's get some info about our USB printer. | First let's get some info about our USB printer. | ||
# lsusb | grep Printer | # lsusb.py -uU | grep Printer | ||
3-2 04b8:0007 00 1IF [USB 2.00, 480 Mbps, 2mA] (EPSON USB2.0 Printer (Hi-speed) 55PKAZZ15776790829) | |||
# grep -H "" /sys/bus/usb/devices/usb3/3-2/{id{Vendor,Product},bcdDevice} | |||
/sys/bus/usb/devices/usb3/3-2/idVendor:04b8 | |||
/sys/bus/usb/devices/usb3/3-2/idProduct:0007 | |||
/sys/bus/usb/devices/usb3/3-2/bcdDevice:0100 | |||
These are important for us to distinguish our printer. | |||
# cat >> /etc/mdev.conf <<EOF | # cat >> /etc/mdev.conf <<EOF | ||
Line 57: | Line 50: | ||
CUPS will be able now to use libusb to discover the local USB printer. | CUPS will be able now to use libusb to discover the local USB printer. | ||
== Desktop usage == | |||
Additionally, in a desktop environment check whether ''root'' and the user's username (''yourusername'') are already members of the <code>lp</code> and <code>lpadmin</code> groups. | |||
Additionally, in a desktop environment | {{Note| A '''user''' needs be added to the <code>lpadmin</code> group, if they should be able to administer the CUPS system with their password}} | ||
$ groups root | |||
$ | root bin daemon sys adm disk wheel floppy dialout tape video | ||
$ groups ''yourusername'' | |||
$ | yourusername disk wheel audio cdrom dialout video users plugdev | ||
If not, add them: | If not, add them: | ||
{{Cmd|# adduser root lp | |||
# adduser root lpadmin | |||
# adduser ''yourusername'' lp | |||
# adduser ''yourusername'' lpadmin}} | |||
Start CUPS ('''cupsd''') and make it persist between boots; then reboot: | Start CUPS ('''cupsd''') and make it persist between boots; then reboot: | ||
{{Cmd|# rc-service cupsd start | |||
# rc-update add cupsd | |||
# reboot}} | |||
== Managing Printers via KDE Plasma Settings == | |||
To manage printers from KDE Plasma Settings, it is required to add "root" to SystemGroup in '''''/etc/cups/cups-files.conf'''''. | |||
e.g. | |||
{{Cmd| | |||
SystemGroup root lpadmin}} | |||
== Managing Printers via Command Line == | |||
Credit to ArchWiki's excellent [https://wiki.archlinux.org/index.php/CUPS CUPS] page for guidance with the following basic steps. | Credit to ArchWiki's excellent [https://wiki.archlinux.org/index.php/CUPS CUPS] page for guidance with the following basic steps. | ||
=== Locate your printer === | |||
With your printer connected and powered on, determine the ''URI'' for your printer. Depending on whether the connection is via '''usb''' or '''parallel''' ports, the URI will carry a <code>usb://</code> or <code>parallel:/</code> prefix. | With your printer connected and powered on, determine the ''URI'' for your printer. Depending on whether the connection is via '''usb''' or '''parallel''' ports, the URI will carry a <code>usb://</code> or <code>parallel:/</code> prefix. | ||
Line 97: | Line 103: | ||
In the example above, the URI is <code>usb://HP/LaserJet%202200</code> | In the example above, the URI is <code>usb://HP/LaserJet%202200</code> | ||
=== Find a .ppd or .ppd.gz ''driver'' === | |||
If your printer supports ''IPP Everywhere'' -- most recent models do -- see the ''driverless'' command in ''cups-filters'': | If your printer supports ''IPP Everywhere'' -- most recent models do -- see the ''driverless'' command in ''cups-filters'': | ||
Line 118: | Line 124: | ||
From the results, you might select the following .ppd ''driver'': | From the results, you might select the following .ppd ''driver'': | ||
drv:///hp/hpcups.drv/hp-laserjet_2200_series.ppd | drv:///hp/hpcups.drv/hp-laserjet_2200_series.ppd | ||
If required, additional drivers can be obtained by installing | If required, additional drivers can be obtained by installing {{Pkg|gutenprint}}, and running the <code>lpinfo</code> search again. These may not specify <code>.ppd</code> names. | ||
{{Cmd|# apk add gutenprint gutenprint-doc}} | |||
=== Configure a queue === | |||
Create a queue using a ''queue_name'' of your choice. Your selected printer's name is an obvious choice, but do not use spaces.<BR> | Create a queue using a ''queue_name'' of your choice. Your selected printer's name is an obvious choice, but do not use spaces.<BR> | ||
Line 155: | Line 162: | ||
== See also == | == See also == | ||
* [[mDNS|Use mDNS to discover printers]] | |||
* [https://www.cups.org/documentation.html CUPS documentation] | * [https://www.cups.org/documentation.html CUPS documentation] | ||
[[Category:Printers]] | [[Category:Printers]] | ||
Latest revision as of 18:42, 7 May 2025
CUPS is a modular printing system for Unix-like computer operating systems. This page explains how to install and configure printers in Alpine Linux.
Installation
Install the basic packages need for configuring printers:
# apk add cups cups-filters
As of now, cups-pdf package is available in the testing repository. It can be safely installed by following the guidelines as per the below command:
# apk add cups-pdf@testing
Service configuration
Confirm that cups OpenRC service starts. You may also set it to run at boot-up.
# rc-service cupsd start
# rc-update add cupsd boot
Printer configuration
Go to http://localhost:631
with your web browser and follow the steps to "Add Printer". It will ask you to log in to add a printer. Log in as root, then finish the steps. Once you're done, you should be able to print.
hplip package was available in the Repositories repository until V3.20 to configure Hewlett-Packard (HP) printers. It can be safely installed as per the below command:# apk add hplip
If that doesn't work, you may also need to add HPLIP's dependencies separately. There are currently no packages for CUPS DDK, hp-setup
or foomatic
.
# apk add ghostscript py3-reportlab libjpeg net-snmp
![]() Modifications/sections required e.g. to address container user-case scenarios, etc. |
Configure mdev for USB printers
By default USB printer with mdev would have ownership root:root and permission 0660. As cupsd would try to open a libusb-based printer as lp user, it won't have permission to use the device in /dev/bus/usb.
First let's get some info about our USB printer.
# lsusb.py -uU | grep Printer 3-2 04b8:0007 00 1IF [USB 2.00, 480 Mbps, 2mA] (EPSON USB2.0 Printer (Hi-speed) 55PKAZZ15776790829)
# grep -H "" /sys/bus/usb/devices/usb3/3-2/{id{Vendor,Product},bcdDevice} /sys/bus/usb/devices/usb3/3-2/idVendor:04b8 /sys/bus/usb/devices/usb3/3-2/idProduct:0007 /sys/bus/usb/devices/usb3/3-2/bcdDevice:0100
These are important for us to distinguish our printer.
# cat >> /etc/mdev.conf <<EOF SUBSYSTEM=usb;PRODUCT=4b8/7/100;.* root:lp 660 */lib/mdev/usbdev EOF
Unplug the USB cable and plug it in again. Now the USB printer device at /dev/bus/usb/ will have valid ownership and permissions.
# ls -l /dev/bus/usb/002/011 crw-rw---- 1 root lp 189, 138 Apr 14 21:19 /dev/bus/usb/002/011
CUPS will be able now to use libusb to discover the local USB printer.
Desktop usage
Additionally, in a desktop environment check whether root and the user's username (yourusername) are already members of the lp
and lpadmin
groups.
lpadmin
group, if they should be able to administer the CUPS system with their password$ groups root
root bin daemon sys adm disk wheel floppy dialout tape video
$ groups yourusername
yourusername disk wheel audio cdrom dialout video users plugdev
If not, add them:
# adduser root lp # adduser root lpadmin # adduser yourusername lp # adduser yourusername lpadmin
Start CUPS (cupsd) and make it persist between boots; then reboot:
# rc-service cupsd start # rc-update add cupsd # reboot
Managing Printers via KDE Plasma Settings
To manage printers from KDE Plasma Settings, it is required to add "root" to SystemGroup in /etc/cups/cups-files.conf.
e.g.
SystemGroup root lpadmin
Managing Printers via Command Line
Credit to ArchWiki's excellent CUPS page for guidance with the following basic steps.
Locate your printer
With your printer connected and powered on, determine the URI for your printer. Depending on whether the connection is via usb or parallel ports, the URI will carry a usb://
or parallel:/
prefix.
$ lpinfo -v # network lpd network socket network beh file cups-brf:/ direct usb://HP/LaserJet%202200 network ipp network ipps network https network http direct hp
In the example above, the URI is usb://HP/LaserJet%202200
Find a .ppd or .ppd.gz driver
If your printer supports IPP Everywhere -- most recent models do -- see the driverless command in cups-filters:
$ driverless ipp_uri > printer.ppd
or just pass -m everywhere to lpadmin.
Otherwise, you could list all the drivers available by running lpinfo -m
and then searching through the results to find a .ppd or .ppd.gz specific to your printer. A quick solution is to use the --make-and-model
flag and grep
to filter the results by plugging in your printer's make, model and series in this fashion:
$ lpinfo --make-and-model "make_and_model_names" -m | grep -i printer_series
- Search for the term HP to find instances of Hewlett-Packard.
- You do not need to state the
printer_series
in whole if at all e.g. 2200 may be preferable to searching for 2200M, etc.
For example, type:
$ lpinfo --make-and-model "HP LaserJet" -m | grep -i 2200
From the results, you might select the following .ppd driver:
drv:///hp/hpcups.drv/hp-laserjet_2200_series.ppd
If required, additional drivers can be obtained by installing gutenprint, and running the lpinfo
search again. These may not specify .ppd
names.
# apk add gutenprint gutenprint-doc
Configure a queue
Create a queue using a queue_name of your choice. Your selected printer's name is an obvious choice, but do not use spaces.
You will also need to be root or use sudo
, and you will also need to plug in the URI and the .ppd driver:
# lpadmin -p queue_name -E -v "uri" -m driver
With this example, you could set as follows, but there are other solutions.
# lpadmin -p HP_LaserJet_2200 -E -v "usb://HP/LaserJet%202200" -m drv:///hp/hpcups.drv/hp-laserjet_2200-pcl3.ppd
This printer queue could be set as default:
# lpoptions -d HP_LaserJet_2200
Printer settings can typically be set in your GUI application's Print menu or by examining the CUPS lpoptions page. If you have a single queue, the setting options available (such as page type, duplex, etc.) for your queue can simply be listed by using the -l flag. Asterisks(*) indicate current settings:
# lpoptions -l PageSize/Media Size: Card3x5 Hagaki Photo4x6 A6 Photo5x7 Card5x8 Oufuku A5 B5 JB5 Executive 16k Letter *A4 ExecutiveJIS FLSA Legal EnvA2 EnvC6 EnvChou4 EnvMonarch EnvDL Env10 EnvChou3 EnvC5 EnvB5 Custom.WIDTHxHEIGHT Duplex/Double-Sided Printing: DuplexNoTumble DuplexTumble *None InputSlot/Media Source: *Auto PhotoTray Upper Lower Envelope LargeCapacity Manual MPTray ColorModel/Output Mode: *Gray MediaType/Media Type: *Plain OutputMode/Print Quality: *Normal Draft Best OptionDuplex/Duplexer Installed: *False True
If there is only one queue, options can be set by simply using -o flags for each setting:
# lpoptions -o PageSize=Legal -o Duplex=DuplexNoTumble