热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Linuxlpadmin命令增加usb打印机

前言因为要在linux用命令添加USB打印机,所以就有了这个博客。文章目录前言Step1安装CupsStep2配置Cups允许添加设备节点作为打印机Step3查看U

前言

因为要在linux 用命令添加USB打印机,所以就有了这个博客。


文章目录

  • 前言
  • Step 1 安装 Cups
  • Step2 配置Cups 允许添加设备节点作为打印机
  • Step 3 查看USB打印机节点
  • Step 4 lpadmin 添加打印机
  • Step 5 测试打印


Step 1 安装 Cups

一般使用Ubuntu 系统的话,默认系统会安装cups 组件用来控制打印机。
如果使用lpadmin 命令提示无法找到命令,执行一下apt安装一下 cups

sudo apt-get install cups

Step2 配置Cups 允许添加设备节点作为打印机

sudo vim /etc/cups/cups-files.conf

然后在 cups-files.conf 文件中 找到 FileDevice 属性 然后 将值设置为 Yes
设置完成后的文件

#
# File/directory/user/group configuration file for the CUPS scheduler.
# See "man cups-files.conf" for a complete description of this file.
## List of events that are considered fatal errors for the scheduler...
#FatalErrors config# Do we call fsync() after writing configuration or status files?
#SyncOnClose Yes# Default user and group for filters/backends/helper programs; this cannot be
# any user or group that resolves to ID 0 for security reasons...
#User lp
#Group lp# Administrator user group, used to match @SYSTEM in cupsd.conf policy rules...
# This cannot contain the Group value for security reasons...
SystemGroup lpadmin# User that is substituted for unauthenticated (remote) root accesses...
#RemoteRoot remroot# Do we allow file: device URIs other than to /dev/null?
# 设置在此处!!!!!!!!!!
FileDevice Yes# Permissions for configuration and log files...
#ConfigFilePerm 0640
#LogFilePerm 00640# Location of the file logging all access to the scheduler; may be the name
# "syslog". If not an absolute path, the value of ServerRoot is used as the
# root directory. Also see the "AccessLogLevel" directive in cupsd.conf.
AccessLog /var/log/cups/access_log# Location of cache files used by the scheduler...
#CacheDir /var/cache/cups# Location of data files used by the scheduler...
#DataDir /usr/share/cups# Location of the static web content served by the scheduler...
#DocumentRoot /usr/share/cups/doc-root# Location of the file logging all messages produced by the scheduler and any
# helper programs; may be the name "syslog". If not an absolute path, the value
# of ServerRoot is used as the root directory. Also see the "LogLevel"
# directive in cupsd.conf.
ErrorLog /var/log/cups/error_log# Location of fonts used by older print filters...
#FontPath /usr/share/cups/fonts# Location of LPD configuration
#LPDConfigFile # Location of the file logging all pages printed by the scheduler and any
# helper programs; may be the name "syslog". If not an absolute path, the value
# of ServerRoot is used as the root directory. Also see the "PageLogFormat"
# directive in cupsd.conf.
PageLog /var/log/cups/page_log# Location of the file listing all of the local printers...
#Printcap /run/cups/printcap# Format of the Printcap file...
#PrintcapFormat bsd
#PrintcapFormat plist
#PrintcapFormat solaris# Location of all spool files...
#RequestRoot /var/spool/cups# Location of helper programs...
#ServerBin /usr/lib/cups# SSL/TLS keychain for the scheduler...
#ServerKeychain ssl# Location of other configuration files...
#ServerRoot /etc/cups# Location of Samba configuration file...
#SMBConfigFile # Location of scheduler state files...
#StateDir /run/cups# Location of scheduler/helper temporary files. This directory is emptied on
# scheduler startup and cannot be one of the standard (public) temporary
# directory locations for security reasons...
#TempDir /var/spool/cups/tmp

Step 3 查看USB打印机节点

使用 dmesg 命令查看一下 usb 设备插入后的设备是否能够识别成为打印机

# dmesg
[87203.338517] usb 1-1.2: Product: HP LaserJet 1020
[87203.338529] usb 1-1.2: Manufacturer: Hewlett-Packard
[87203.338543] usb 1-1.2: SerialNumber: S418K7W
[87203.340431] usblp 1-1.2:1.0: usblp0: USB Bidirectional printer dev 95 if 0 alt 0 proto 2 vid 0x03F0 pid 0x2B17

看到这个 usblp0: USB Bidirectional printer 就说明 打印机识别了,没有识别就是一个普通的usb设备,此时需要去找这个设备的驱动才可以。

在使用lsusb 查看打印机的Device id 以及绑定的usb总线

# lsusb
Bus 001 Device 095: ID 03f0:2b17 Hewlett-Packard LaserJet 1020

然后可以看到 在bus 001 上 生成的095 的设备
此时可以查看一下

# ll /dev/bus/usb/001
crw-rw-r--+ 1 root lp 189, 94 4月 4 10:57 095

看到有lp 标志 说明 这个设备是个打印机,并且device id 是 095


Step 4 lpadmin 添加打印机

先得下载驱动
https://github.com/koenkooi/foo2zjs 这个地方找到你打印机的PPD 文件。
下载好放到运行目录。

找到节点就很简单了,用lpadmin 添加打印机就好了

# lpadmin -p printer -E -v /dev/bus/usb/001/095 -P ./HP-LaserJet_1020.ppd

这样就添加了一个名称为 printer 的打印机


Step 5 测试打印

file1.pdf 必须存在

# lpr -P printer file1.pdf

此时就可以打印出内容了


推荐阅读
  • 本文介绍了作者在开发过程中遇到的问题,即播放框架内容安全策略设置不起作用的错误。作者通过使用编译时依赖注入的方式解决了这个问题,并分享了解决方案。文章详细描述了问题的出现情况、错误输出内容以及解决方案的具体步骤。如果你也遇到了类似的问题,本文可能对你有一定的参考价值。 ... [详细]
  • 本文介绍了在Mac上搭建php环境后无法使用localhost连接mysql的问题,并通过将localhost替换为127.0.0.1或本机IP解决了该问题。文章解释了localhost和127.0.0.1的区别,指出了使用socket方式连接导致连接失败的原因。此外,还提供了相关链接供读者深入了解。 ... [详细]
  • 本文介绍了在rhel5.5操作系统下搭建网关+LAMP+postfix+dhcp的步骤和配置方法。通过配置dhcp自动分配ip、实现外网访问公司网站、内网收发邮件、内网上网以及SNAT转换等功能。详细介绍了安装dhcp和配置相关文件的步骤,并提供了相关的命令和配置示例。 ... [详细]
  • Nginx使用AWStats日志分析的步骤及注意事项
    本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。 ... [详细]
  • Skywalking系列博客1安装单机版 Skywalking的快速安装方法
    本文介绍了如何快速安装单机版的Skywalking,包括下载、环境需求和端口检查等步骤。同时提供了百度盘下载地址和查询端口是否被占用的命令。 ... [详细]
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 本文介绍了Java工具类库Hutool,该工具包封装了对文件、流、加密解密、转码、正则、线程、XML等JDK方法的封装,并提供了各种Util工具类。同时,还介绍了Hutool的组件,包括动态代理、布隆过滤、缓存、定时任务等功能。该工具包可以简化Java代码,提高开发效率。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • 预备知识可参考我整理的博客Windows编程之线程:https:www.cnblogs.comZhuSenlinp16662075.htmlWindows编程之线程同步:https ... [详细]
  • 本文介绍了Oracle存储过程的基本语法和写法示例,同时还介绍了已命名的系统异常的产生原因。 ... [详细]
  • SpringBoot整合SpringSecurity+JWT实现单点登录
    SpringBoot整合SpringSecurity+JWT实现单点登录,Go语言社区,Golang程序员人脉社 ... [详细]
  • 使用圣杯布局模式实现网站首页的内容布局
    本文介绍了使用圣杯布局模式实现网站首页的内容布局的方法,包括HTML部分代码和实例。同时还提供了公司新闻、最新产品、关于我们、联系我们等页面的布局示例。商品展示区包括了车里子和农家生态土鸡蛋等产品的价格信息。 ... [详细]
  • Ihaveaworkfolderdirectory.我有一个工作文件夹目录。holderDir.glob(*)>holder[ProjectOne, ... [详细]
  • 带添加按钮的GridView,item的删除事件
    先上图片效果;gridView无数据时显示添加按钮,有数据时,第一格显示添加按钮,后面显示数据:布局文件:addr_manage.xml<?xmlve ... [详细]
author-avatar
手机用户2502927925
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有