CUPS(Common Unix Printing System)是Debian的默认打印管理系统,需先安装并启动:
sudo apt update && sudo apt upgrade -y # 更新系统软件包
sudo apt install cups cups-client cups-bsd foomatic-filters -y # 安装CUPS及依赖
sudo systemctl enable cups # 设置开机自启
sudo systemctl start cups # 启动CUPS服务
安装完成后,CUPS会监听631端口(本地可通过http://localhost:631访问管理界面)。
驱动安装方式取决于打印机品牌和型号:
printer-driver-all,可覆盖大部分打印机:sudo apt install printer-driver-all -y
hplip(HP Linux Imaging and Printing)套件,包含驱动和管理工具:sudo apt install hplip hplip-gui -y
epson-inkjet-printer-escpr驱动(支持多数Epson喷墨打印机):sudo apt install epson-inkjet-printer-escpr -y
.deb格式驱动包。下载完成后,通过以下命令安装:sudo dpkg -i /path/to/downloaded-driver.deb # 替换为实际驱动路径
sudo apt --fix-broken install # 修复可能的依赖问题
http://localhost:631,输入管理员账号密码登录。lpadmin工具添加。例如,添加USB打印机:sudo lpadmin -p PrinterName -E -v usb://PrinterManufacturer/PrinterModel -m drv:///hpcups.drv/PrinterModel.ppd -D "Printer Location" -P /path/to/ppd/file.ppd
其中:PrinterName为自定义打印机名称(如HP_LaserJet);-v指定设备URI(USB打印机为usb://开头,网络打印机为ipp://开头);-m指定PPD驱动文件路径(可通过lpinfo -m查看可用驱动)。添加完成后,可通过以下方式验证:
echo "Debian Printer Test" > test.txt # 创建测试文件
lpr -P PrinterName test.txt # 发送打印任务(替换为实际打印机名称)
若需让局域网内其他设备使用该打印机,需修改CUPS配置:
sudo nano /etc/cups/cupsd.conf
Listen localhost:631,修改为Listen 0.0.0.0:631(允许所有IP访问)。<Location />部分,修改为:<Location />
Order allow,deny
Allow all
</Location>
sudo systemctl restart cups
其他设备可通过http://Debian主机IP:631访问并添加共享打印机。
sudo systemctl status cups,若未运行则启动sudo systemctl start cups。printer-driver-all通用驱动,或从官网下载最新驱动包;若仍有问题,可访问OpenPrinting数据库查询兼容性。