打印

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Printing and the translation is 71% complete.
Outdated translations are marked like this.

本文档介绍了如何利用CUPS和Samba进行打印机的安装和维护。本文档包含本地打印机和网络打印进的安装以及如何使用网络上其他操作系统的共享打印机等。 有关使用 lp 或者 lpr 命令打印文档的更多信息,详见 CUPS' excellent upstream documentation.

打印与 Gentoo Linux

使用恰当的工具

Linux能够很好的支持各类打印机; CUPS (Common Unix Printing System)是linux下一个很优秀的打印作业服务。自1999年项目建立以来,有关CUPS的安装和维护已经有了相当大的提高和改进。

这篇文当将介绍如何使用CUPS安装和配置本地打印机和网络打印机。 本文档只介绍一些简单的安装和配置信息。需要更详细的信息请参阅 great documentation

安装

内核

当用户希望在系统上安装打印机时,第一步应该知道打印机是如何连接到系统上的。与系统是通过本地端口LPT还是USB,亦或是通过网络? 如果是网络连接的,那么它是使用Internet打印协议(IPP)还是使用Microsoft Windows CIFS协议(Microsoft Windows共享)?

接下来的几个部分将解释在Gentoo系统中使用打印机所需要的最少的内核配置。 当然, 这都是依据打印机是如何连接到系统上而分类的, 这里只是为了方便我们将说明分开几个部分介绍。

首先切换到目录 /usr/src/linux,然后运行 make menuconfig来进入内核配置界面。 如果是使用 genkernel 来配置的内核, 仍然要进行这些步骤以防止某些选项被遗漏。 不要寄希望于 genkernel 来自动的配置系统所有的选项; 打印这部分的配置是很难进行自动设置的。

下一个配置例子中,必要的支持会被设置为编译进内核而不是编译为模块,然后这样编译内核不是强制性的;如果你愿意可以编译为模块,但应记得要在需要的时候应加载这些模块。

现在,可以到你需要的部分去配置(检查)内核选项。

本地打印机 (LPT)

LPT端口通常用于识别并口打印机。 首先需要启用并口支持,然后是 PC样式并口支持 (除非你在使用 SPARC 系统),这样你就启用了并口的支持 。

KERNEL 并行端口打印机配置
Device Drivers --->
  <*> Parallel port support  --->
    <*> PC-style hardware
    [*] IEEE 1284 transfer modes
  Character devices  --->
    <*> Parallel printer support
Note
部分用户可能需要启用Parallel port support中的部分选项。 可通过查看内核配置中 Help 说明获取更详细的信息

That's it! 退出内核配置并且 重新编译内核.

现在继续进行CUPS的安装.

本地打印机 (LPT)

当CUPS使用USB USE标记编译时,可以支持USB本地打印。它使用libusb库来提供用户空间的USB支持。

某些旧版本的软件可能仍需要启用内核中USB打印机的支持。如果内核中编译为模块,则该模块名称为usblp:

KERNEL USB Printer support
Symbol: USB_PRINTER [=n]
Type  :tristate
Prompt: USB Printer support
  Location:
    -> Device Drivers
      -> USB support (USB_SUPPORT [=y])
(1)     -> Support for Host-side USB (USB [=y])
  Defined at drivers/usb/class/Kconfig:21
  Depends on: USB_SUPPORT [=y] && USB [=y]

然而,使用内核中的打印机支持被认为 已经过时。 仅在确定必要的时候使用。

Note
当使用USB转并口端口的适配器时,CUPS可能无法检测到打印机。解决方法是,更改打印机的连接类型,即在 printers.conf 中更改DeviceURI类型并重新启动cupsd服务:
FILE /etc/cups/printers.confModify DeviceURI
# DeviceURI usb:/dev/usb/lp0  replace this line with
DeviceURI parallel:/dev/usb/lp0

远程打印机 (IPP 和 LPD)

为了能够通过Internet打印协议或Line Printer Daemon 协议连接到远程连接的打印机,内核需要启用网络支持。如果已启用网络支持,继续下边的步骤。

远程打印机 (CIFS)

内核必须 支持 CIFS:

KERNEL CIFS 打印机配置
'"`UNIQ--pre-00000007-QINU`"'

CIFS配置完成后,退出内核配置并重新编译内核。不要忘记将新编译的内核拷贝到/boot位置(在此之前如果需要的话记着挂载/boot分区)和更新内核引导,然后重启系统。请注意上述“LPT打印机配置”步骤中的root权限下的命令,了解如何执行这些步骤。

现在继续进行CUPS安装过程中的下一步。

USE 标记

CUPS还有一些可选功能。要启用或禁用这些功能,请使用与它们关联的USE标志。

USE flags for net-print/cups The Common Unix Printing System

X Add support for X11
acl Add support for Access Control Lists
dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
kerberos Add kerberos support
openssl Use dev-libs/openssl instead of net-libs/gnutls for TLS support
pam Add support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
static-libs Build static versions of dynamic libraries as well
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
usb Add USB support to applications that have optional USB support (e.g. cups)
xinetd Add support for the xinetd super-server
zeroconf Support for DNS Service Discovery (DNS-SD)

检查当前的USE标志设置。如若单独为CUPS设置,请将这些USE标志添加到/etc/portage/package.use文件。

root #emerge -pv net-print/cups
[ebuild N     ] net-print/cups-1.7.3  USE="X acl dbus pam ssl threads usb -debug -gnutls -java -kerberos -lprng-compat -python (-selinux) -static-libs -systemd -xinetd -zeroconf" ABI_X86="(64) (-32) (-x32)" LINGUAS="ca es fr it ja pt_BR ru" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" 0 kB

安装

如果确认无误,使用Portage来安装CUPS。

root #emerge --ask net-print/cups

额外的软件

Samba

要启用SAMBA支持, 需要安装net-fs/samba给CUPS提供支持。更新/etc/portage/package.use 文件或者目录来启用cupsUSE标志。

FILE /etc/portage/package.use为samba启用cups USE标志
net-fs/samba cups

然后(重新)安装Samba:

root #emerge --ask --changed-use net-fs/samba

Avahi

Avahi可用于扫描本地网络上的打印机。要使用Avahi主机名连接到联网打印机,请设置.local主机名解析并重新启动CUPS服务。 CUPS需要使用zeroconf USE标志构建。

user $driverless list

配置

打印组

需要使用打印机的用户应被添加到 lp用户组:

root #gpasswd -a username lp

为了能够添加打印机并通过CUPS的Web界面进行编辑,任何允许编辑这些设置的系统用户都应该添加到lpadmin组中:

root #gpasswd -a username lpadmin

服务

OpenRC

如果打印机是在本地连接到系统,并且每次启动后都需要使用打印机,那么CUPS守护程序就需要在启动时自动加载。在CUPS守护程序启动之前,请确保打印机已连接并已打开电源。

root #rc-service cupsd start
root #rc-update add cupsd default

systemd

要使CUPS在系统启动时立即启动并开始工作,输入以下命令:

root #systemctl start cups.service
root #systemctl enable cups.service

HTTP 接口

服务启动后,经过身份验证的用户可以添加打印机。默认情况下root和lpadmin组的任何成员都可以添加。打开web浏览器输入以下URL:

localhost:631

配置文件

CUPS默认的配置文件位于/etc/cups/cupsd.conf,默认配置足以满足大多数用户的需求。然而,某些用户可能需要更改CUPS默认配置。

下一章节涵盖了一些经常需要的配置信息.

  • 允许其他系统使用连接到此Linux工作站的打印机。
  • 从远程系统授予对CUPS管理的访问权限。
  • 配置CUPS以支持Windows PCL驱动程序。建议Windows系统使用SAMBA共享打印机,因为大多数Windows驱动程序都是PCL驱动程序。
  • 将此系统配置为使用远程系统(不是Windows共享)的打印机。

远程打印机

对于通过IPP使用打印机的其他系统,必须在/etc/cups/cupsd.conf文件中明确授予对打印机的访问权限。要使用SAMBA共享打印机,不需要进行此更改。

在喜爱的文本编辑器中打开/etc/cups/cupsd.conf,并为应该能够访问打印机的系统添加Allow 行。在下一个示例中,localhost和IP地址以 192.168.0 开头的任何系统都被授予打印机访问权限。

FILE /etc/cups/cupsd.confAllowing remote access to the printer
<Location />
  Order allow,deny
  Allow localhost
  Allow from 192.168.0.*
</Location>

此行向网络上的客户端广播浏览信息;它将让网络用户知道打印机何时可用:

FILE /etc/cups/cupsd.confBroadcast info
BrowseAddress 192.168.0.*:631

另外,还需要指定端口CUPS侦听,以便它将响应来自网络上其他计算机的打印请求:

FILE /etc/cups/cupsd.confPort configuration
Listen *:631
#Listen localhost:631

CUPS服务会拒绝HTTP请求中的主机名或服务器别名并显示“Bad request”。默认情况下,它适用于IP地址。因此,如果要使用主机名或域打印或浏览CUPS界面,请添加ServerAlias参数:

FILE /etc/cups/cupsd.confServer alias configuration
ServerAlias *

CUPS remote administration

如果需要远程管理,那么就需要对不仅限于localhost的系统授予对CUPS管理的远程访问权限。编辑/etc/cups/cupsd.conf文件,并明确的为每个需要访问权限的系统授予访问权限。例如,要授予对IP地址为192.168.0.3的系统的访问权限:

FILE /etc/cups/cupsd.confAllowing remote access
<Location /admin>
(...)
  Encryption Required
  Order allow,deny
  Allow localhost
  Allow 192.168.0.3
</Location>

修改 /etc/cups/cupsd.conf 文件后,请记住使用 /etc/init.d/cupsd restart 命令重启CUPS守护程序:

启用 Windows PCL 驱动

PCL驱动程序将原始数据发送到打印服务器。要在CUPS上启用原始打印,请编辑/usr/share/cups/mime/mime.types并取消注释 application/octet-stream 行(如果尚未取消注释)。然后编辑/usr/share/cups/mime/mime.convs并执行相同操作(如果尚未取消注释)。

FILE /usr/share/cups/mime/mime.typesEnable support for raw printing
application/octet-stream
FILE /usr/share/cups/mime/mime.convs
application/octet-stream     application/vnd.cups-raw    0    -

进行这些更改后,不要忘记使用/etc/init.d/cupsd restart重新启动CUPS守护程序

配置远程打印机

如果打印机已经被连接到远程的CUPS管理的服务器上,通过修改/etc/cups/client.conf文件可以很方便的配置和使用这些远程打印机.

假设打印机连接到名为 printserver.mydomain 的系统,请使用喜欢的文本编辑器打开 /etc/cups/client.conf 并设置 ServerName 指令:

FILE /etc/cups/client.conf
# (Substitute printserver.mydomain with your print server name)
ServerName printserver.mydomain

远程系统会使用自己的一个默认打印机设置。要更改默认打印机,请使用lpoptions 命令。

首先,显示可用的打印机。

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

将HP LaserJet 5P设置为默认打印机:

root #lpoptions -d hpljet5p

配置打印机

说明

如果要配置的打印机通过其他打印服务器(运行CUPS)远程可用,则不需要以下说明。相反的,请阅读Setting up a Remote Printer.

检测打印机

如果在Linux系统启动时打开USB打印机或并行端口打印机,则可以从内核检索信息中看到成功检测到打印机。这仅仅是打印检测的指示而非要求。

user $dmesg | grep -i print
parport0: Printer, Hewlett-Packard HP LaserJet 2100 Series

对于USB打印机:

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


The lpinfo command can be used in order to list all connected printers:

root #lpinfo -v
network ipp
network http
network socket
network https
network ipps
network lpd
network lpd://BRW67890ABCDEF/BINARY_P1

Running lpinfo -l -v will give a more verbose output.


Listing available drivers

要列出所有可用的驱动,执行一下命令:

user $lpinfo -m

lpinfo 并不是很友好,还有可能有点棘手。如果出现问题,请参阅 man lpinfo 获取更多信息。

安装打印机

要在系统上安装打印机,请启动浏览器并将其指向-{R。打开CUPS Web界面,从中可以执行所有管理任务。

Note
如果在第一次访问界面时使用HTTPS连接与CUPS,则可能需要很长时间才能显示该页面。这是因为第一个请求触发了CUPS SSL证书的生成,这可能是一项耗时的工作。

转到 Administration 并输入框的root登录名和密码信息。然后,当到达管理界面时,单击 Add Printer 。将显示一个新屏幕,允许输入以下信息:

  • spooler name,系统上用于识别打印机的简短描述性名称。此名称不应包含空格或任何特殊字符。例如,对于HP LaserJet 5P,标题为 hpljet5p </ code>。
  • location,描述打印机的物理位置(例如“卧室”或“在洗碗机旁边的厨房中”等)。这有助于维护多台打印机。
  • description,打印机的完整描述。常见用途是完整的打印机名称(如“HP LaserJet 5P”)。

下一个屏幕请求打印机监听的设备。这里将介绍几种设备的选择。下表列出了一些可能的设备,但该列表并非详尽无遗。

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

如果安装远程打印机,将查询打印机的URL:

  • LPD打印服务器地址是 lpd://hostname/queue
  • HP JetDirect打印机地址为socket://hostname
  • IPP 打印机地址为 ipp://hostname/printers/printername 或者 http://hostname:631/printers/printername

接下来,在随后的屏幕中选择相邻屏幕中的打印机制造商以及型号类型和编号。对于各种打印机,将提供不同的打印驱动程序。现在选择一个或在OpenPrinting Printer List上搜索一个好的驱动程序。驱动程序可以在以后轻松更改。

选择驱动程序后,CUPS将通知打印机已成功添加到系统中。导航到管理界面上的打印机管理页面,然后选择 Configure Printer来更改打印设置(分辨率、页面格式等等)。

测试与重新配置打印机

要验证打印机是否正常工作,请转到打印机管理页面,选择打印机并单击打印测试页

如果打印机不能正常工作,点击 修改打印机来重新配置打印机。与首次配置相同的界面会显示出来,显示的选项就是当前的配置。

如果打印机不能正常工作,可以从CUPS错误日志中查看信息。日志位于 /var/log/cups/error_log。下面的例子中显示出了权限错误,很可能是因为 /etc/cups/cupsd.conf文件中Allow行错误的配置。

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

安装合适的驱动程序

驱动程序很多,找出最适合的驱动,请访问 OpenPrinting Printer List。选择打印机品牌和型号类型来选择推荐的驱动。例如,对于打印机HP LaserJet 5P,推荐的驱动程序为ljet4驱动。

从网页下载PPD文件,并放置于/usr/share/cups/model中,然后在root权限下运行 /etc/init.d/cupsd restart。这将使这个驱动程序能在CUPS网页界面下可用。现在按照上边说明重新配置打印机。

Enabling job accounting in for Xerox printers

High-end Xerox printers (often a gray, cabinet sized device) use XCPT PDL, and XML based, and poorly documented XPIF ticketing instruction format.

XCPT filter in Cups never made it to a release grade, and the work on it was eventually dropped and all XPIF must be input into a PPD manually. Luckily, it's largely a direct copy of IPP, using XML syntax. After peeking into docs available online, we can craft an arbitrary XPIF command using corresponding IPP attributes.

To configure XPIF solely for ticketing/accounting, drop the following into any PPD:

CODE XPIF code for inserting a user id
*JCLBegin:"<1B>%-12345X@PJL JOB<0A>"

*% Base JCL key code option
*JCLOpenUI JCLPasscode/Key Code: PickOne
*OrderDependency: 10 JCLSetup *JCLPasscode
*JCLPasscode None/No Code: ""
*JCLCloseUI: *JCLPasscode

*% Custom JCL key code option
*CustomJCLPasscode True: "@PJL XCPT <?xml version=<22>1.0<22> encoding=<22>UTF-8<22>?>
  @PJL XCPT <!DOCTYPE xpif SYSTEM <22>xpif-v02074.dtd<22><3E>
  @PJL XCPT <xpif version=<22>1.0<22> cpss-version=<22>2.07<22> xml:lang=<22>en-US<22><3E>
  @PJL XCPT          <job-template-attributes>
  @PJL XCPT <09><09><3C>job-accounting-user-id syntax=<22>name<22> xml:space=<22>preserve<22><3E>\1<3C>/job-accounting-user-id>
  @PJL XCPT          </job-template-attributes>
  @PJL XCPT </xpif>"
*ParamCustomJCLPasscode Code/Key Code: 1 password 0 16

*JCLEnd:"<1B>%-12345X@PJL EOJ<0A><1B>%-12345X<0A>"

It will draw a dropdown box in any printing ui compliant with CUPS PPD extensions to enter the id.

The long term solution would still be for Xerox to fully publish XPIF, and XCPT specifications, to allow for a proper XPIF cups filter to be developed.

使用专用的打印机驱动程序

说明

某些打印机需要专用的驱动程序或不能通过常规配置过程启用的额外的功能(如上所述)。本章将讨论一系列打印机以及它们如何与Gentoo Linux配合使用。

Gutenprint 驱动

Gutenprint 驱动程序是高品质的开源打印机驱动程序,适用于支持CUPS的各种Canon、Epson、HP、Lexmark、Sony、Olympus和PCL打印机。它们同样支持ghostscript、Gimp和其他应用程序。

Gentoo的Portage树包含一个用于gutenprint驱动程序的ebuild。运行emerge gutenprint进行安装。请注意ebuild请求相当少的USE标志。要使gutenprint驱动程序正常工作,必须启用cupsppds

root #emerge --ask net-print/gutenprint

当emerge进程结束后,通过CUPS Web界面即可使用gutenprint驱动。

HPLIP 驱动

查看 HPLIP Driver.

Lexmark driver

Most Lexmark printers are handled by their "Universal Printer Driver":

root #emerge --ask net-print/lexmark-upd-ppd

Once this is installed, there is a single Lexmark driver available in the CUPS setup wizard that should work with most printers and MFDs.

PNM2PPA 驱动

PPA是惠普的一种不面向打印机而是专注于向系统发送低级别的数据处理的技术,这使得打印机更便宜但更耗费资源。

如果 OpenPrinting 显示 pnm2ppa 驱动是最好的选择, 那么 net-print/pnm2ppa filter 必须安装到系统:

root #emerge --ask net-print/pnm2ppa

安装后,下载打印机OpenPrinting 的PPD文件并将其放在/usr/share/cups/model 文件夹中。然后使用上述步骤配置打印机。

SpliX 驱动

SpliX是一套用于SPL(三星打印机语言)打印机的CUPS打印机驱动程序。虽然SpliX驱动程序也可通过OpenPrinting获得,但net-print/splix软件包允许portage树快速管理这些驱动程序。要安装此包请运行:

root #emerge --ask net-print/splix

并且重启 cupsd.

Brother 打印机驱动

Canon 打印驱动

请查看下列页面:

与微软Windows系统协同打印

Note
阅读 Samba/CUPS Guide 获取详细的信息来使用Samba配置CUPS.

配置Windows IPP客户端

Microsoft Windows系统支持IPP(Windows 9x和ME用户需要单独安装)。要在Windows上安装连接到linux系统上的打印机,请启动“添加打印机”向导并选择“网络打印机”。当询问URI时,请使用http://hostname:631/printers/queue

配置Windows客户端来使用Samba共享打印机

要在CIFS网络上共享打印机,必须正确安装和配置SAMBA。如何配置做虽然超出了本文的范围,本文也涵盖了针对共享打印机的SAMBA的一些快速配置。

利用文本编辑器打开/etc/samba/smb.conf并添加[printers]段:

CODE [printers] section
[printers]
  comment      = All printers
  path         = /var/spool/samba
  browseable   = no
  guest ok     = no
  writable     = no
  printable    = yes
  public       = yes
  printer name = hpljet5p

转到smb.conf文件的顶部 [global]部分,找到printcap nameprinting设置,并将它们设置为cups(参见下面的示例):

CODE Changing the [global] section of smb.conf
[global]
  (...)
  printcap name = cups
  printing      = cups

确保在CUPS中启用了Windows PCL 支持。 然后重启smb服务使更改的配置生效。

配置Linux客户端使用Windows打印服务

首先确保在Windows系统中启用共享打印机并且使用cups USE安装net-fs/samba

要查找所需的打印机URI,请运行以下命令,将server替换为要探测samba共享打印机的计算机:

user $smbclient -N '\\server\'

在CUPS Web界面中,如前所述配置打印机。注意CUPS已经添加了另一个名为Windows Printer via SAMBA的驱动程序。选择它并使用smb://username:password@workgroup/server/printernamesmb://server/printername

Important
所有URI中特殊字符都应该进行转换一遍正确引用。例如:

smb://BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6

应转换为:

smb://BEN-DESKTOP/HP%20Color%20LaserJet%20CP1510%20series%20PCL6

可以运行以下命令来获取转换后的字符串:

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

打印相关的程序

简介

有许多工具可以帮助配置打印机,使用其他打印过滤器,为打印添加功能等。本章将列出其中的一些。请注意,该列表并非详尽无遗,并且这里并不打算详细讨论每个工具。

Gtk-LP - 一个GTK打印配置工具

使用net-print/gtklp可以从独立的GTK +应用程序执行打印机的安装,修改和配置。它使用CUPS并提供所有标准CUPS功能。如果不喜欢CUPS Web界面或者需要用于日常打印例程的独立应用程序,那么绝对值得一试。

通过以下命令来安装:

root #emerge --ask net-print/gtklp

KDE Plasma环境下的配置工具

KDE Plasma同样有一个叫做kde-apps/print-manager的打印机配置工具。它协同CUPS提供一个友好的界面来配置打印机。可以运行以下命令来安装:

root #emerge --ask kde-apps/print-manager

卸载

USE flags

使用cups USE 标志的程序包必须进行修改。 通过查找 /etc/portage/package.use 确认是否有明确添加cups 标志的包并移除。

然后,需要从/etc/portage/make.confUSE中移除cups(如果存在的话)。

卸载

root #emerge --ask --depclean --verbose net-print/cups

最后,清理那些因CUPS包而引入的一些依赖程序。

root #emerge --ask --depclean

Troubleshooting

Debugging

See archlinux wiki

Error: Unable to convert file 0 to printable format

While having printing troubles and /var/log/cups/error_log shows this message:

CODE Error log
Unable to convert file 0 to printable format

Re-emerge app-text/ghostscript-gpl with the cups USE flag. You can either add cups to the system USE flags in /etc/portage/make.conf or enable it only for ghostscript-gpl as shown:

root #echo "app-text/ghostscript-gpl cups" >> /etc/portage/package.use

Then run emerge app-text/ghostscript-gpl. When it has finished compiling, be sure to restart cupsd afterward.

When using OpenRC:

root #service cupsd restart

When using systemd:

root #systemctl restart cups

USB printer is not detected

Assuming that cups is built with the usb USE flag, verify that the printer's character device has the correct permissions. For example:

user $lsusb Bus 002 Device 058: ID 04e8:3297 Samsung Electronics Co., Ltd ML-191x/ML-252x Laser Printer

There should be a character device for this printer at /dev/bus/usb/002/058.

user $ls -l /dev/bus/usb/002/058 crw-rw-r-- 1 root android 189, 185 Apr 16 05:55 /dev/bus/usb/002/058

In this example, /lib64/udev/rules.d/80-android.rules over-zealously modified the permissions. This is bug #644636. Lets try fixing them:

root #chgrp lp /dev/bus/usb/002/058
root #chmod 660 /dev/bus/usb/002/058

Now we should see:

user $ls -l /dev/bus/usb/002/058 crw-rw---- 1 root lp 189, 185 Apr 16 05:55 /dev/bus/usb/002/058

The printer likely is detected now. You should be able to add it, configure it (provided that you have a working driver) and print a test page. This implies a permissions problem. Assuming that your system uses udev/eudev for managing its /dev directory, you can make this change permanent by making a udev file:

FILE /etc/udev/rules.d/99-printer.rulesCustom Udev Rule
SUBSYSTEMS=="usb", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3297", MODE="0660", GROUP="lp"

Our device is "ID 04e8:3297" according to the earlier lsusb output. We split that into idVendor and idProduct as demonstrated in the example. Now udev should ensure that the correct permissions are set at every boot and at every hotplug.

See also

外部资源


This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Sven Vermeulen (SwifT) ,
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.