Print Server with CUPS

Level: Advanced Module: File Sharing & Print 11 min read Lesson 39 of 66

Overview

  • What you will learn: How to install and configure CUPS (Common Unix Printing System) as a network print server on Ubuntu. You will understand the Internet Printing Protocol (IPP), manage printers with lpadmin, create printer classes for load balancing, set up cups-pdf for virtual PDF printing, and configure cupsd.conf for network sharing.
  • Prerequisites: Basic Linux system administration, understanding of networking concepts and firewall configuration
  • Estimated reading time: 18 minutes

IPP Protocol and CUPS Architecture

CUPS is the standard printing system on Linux and macOS. It uses the Internet Printing Protocol (IPP) — an HTTP-based protocol running on port 631 — to manage print jobs, query printer status, and communicate between clients and print servers. IPP replaced older protocols like LPD (Line Printer Daemon) and provides features such as authentication, encryption, and job management.

The CUPS architecture consists of several components. The cupsd daemon listens for print requests and manages the print queue. Backends handle communication with physical printers via USB, parallel port, network (IPP, LPD, SMB), or virtual destinations. Filters convert document formats (PDF, PostScript, raster) into the printer’s native language. PPD files (PostScript Printer Description) describe printer capabilities such as paper sizes, resolution, and duplex support.

# CUPS architecture overview:
#
# Application  -->  CUPS Client API  -->  cupsd (scheduler)
#                                            |
#                   +------------------------+------------------------+
#                   |                        |                        |
#               Filter chain            PPD/Driver              Backend
#            (format conversion)     (printer capabilities)   (output device)
#                   |                                             |
#               PDF -> PS -> Raster                    USB / Network / PDF
#
# Key files and directories:
# /etc/cups/cupsd.conf     — Main daemon configuration
# /etc/cups/printers.conf  — Printer definitions (auto-generated)
# /etc/cups/ppd/           — PPD files for installed printers
# /var/spool/cups/         — Print job spool directory
# /var/log/cups/           — Log files (access_log, error_log)

# IPP protocol details:
# Port: 631 (HTTP/HTTPS)
# Operations: Print-Job, Get-Printer-Attributes, Get-Jobs, Cancel-Job
# URIs: ipp://server:631/printers/printer-name
# Web interface: https://server:631/

Installing CUPS and Managing Printers with lpadmin

CUPS is typically pre-installed on Ubuntu desktop systems, but server installations require manual setup. The lpadmin command is the primary tool for adding, modifying, and removing printers from the command line.

# Install CUPS
$ sudo apt update
$ sudo apt install cups cups-client cups-bsd

# Start and enable the CUPS service
$ sudo systemctl enable cups
$ sudo systemctl start cups

# Add your user to the lpadmin group for printer management
$ sudo usermod -aG lpadmin $USER

# List available backends and discover network printers
$ lpinfo -v
# network ipp://192.168.1.50:631/ipp/print
# direct usb://HP/LaserJet?serial=ABC123
# network socket://192.168.1.51:9100

# List available drivers/PPDs
$ lpinfo -m | grep -i "laser"

# Add a network printer using lpadmin
$ sudo lpadmin -p OfficeHP -E 
    -v ipp://192.168.1.50:631/ipp/print 
    -m everywhere 
    -D "Office HP LaserJet" 
    -L "Building A, Room 101"

# Add a printer with a specific PPD
$ sudo lpadmin -p WarehouseBro -E 
    -v socket://192.168.1.51:9100 
    -P /usr/share/ppd/brother/brother_hl2270dw.ppd 
    -D "Warehouse Brother Printer" 
    -L "Warehouse Floor"

# Set default printer options
$ sudo lpadmin -p OfficeHP -o media=A4 -o sides=two-sided-long-edge

# Set the default printer
$ sudo lpadmin -d OfficeHP

# Disable/enable a printer
$ sudo cupsdisable OfficeHP -r "Maintenance in progress"
$ sudo cupsenable OfficeHP

# Remove a printer
$ sudo lpadmin -x OldPrinter

# Print a test page
$ lp -d OfficeHP /usr/share/cups/data/testprint

# Check printer status
$ lpstat -p -d
$ lpstat -t

The -E flag enables the printer and accepts jobs immediately. The -m everywhere option uses IPP Everywhere driverless printing, which works with most modern network printers without requiring vendor-specific PPD files. For older printers, you may need to install specific driver packages and reference their PPD files with the -P option.

Printer Classes and cups-pdf

Printer classes group multiple physical printers under a single logical name for load balancing and redundancy. When a job is sent to a class, CUPS routes it to the first available printer. The cups-pdf package creates a virtual printer that generates PDF files instead of physical output — invaluable for testing and document archival.

# Create a printer class for load balancing
$ sudo lpadmin -p Floor2-HP -E -v ipp://192.168.1.50:631/ipp/print -m everywhere
$ sudo lpadmin -p Floor2-Bro -E -v socket://192.168.1.51:9100 -m everywhere

# Add printers to a class
$ sudo lpadmin -c Floor2-Printers -p Floor2-HP
$ sudo lpadmin -c Floor2-Printers -p Floor2-Bro

# Set the class as default
$ sudo lpadmin -d Floor2-Printers

# View class members
$ lpstat -c Floor2-Printers

# Remove a printer from a class
$ sudo lpadmin -r Floor2-Printers -p Floor2-Bro

# Install cups-pdf virtual printer
$ sudo apt install cups-pdf

# cups-pdf is auto-configured — verify it appears
$ lpstat -p PDF

# Print to PDF
$ lp -d PDF /etc/hostname

# PDF output location (per-user):
# /home/username/PDF/
# For root: /var/spool/cups-pdf/ANONYMOUS/

# Configure cups-pdf behavior
$ sudo nano /etc/cups/cups-pdf.conf
# Key settings:
# Out       ${HOME}/PDF        — output directory
# Grp       lpadmin            — group ownership of PDFs
# UserUMask 0077               — restrictive file permissions
# PostProcessing /usr/local/bin/pdf-notify.sh  — run script after PDF creation

# Job management commands
$ lpq                          # View the print queue
$ lpq -P OfficeHP              # View queue for specific printer
$ lprm 123                     # Cancel job 123
$ cancel -a                    # Cancel all jobs
$ lp -d OfficeHP -n 3 file.pdf # Print 3 copies

Web Administration and Network Sharing

CUPS includes a built-in web administration interface accessible at https://localhost:631. For a network print server, you need to configure cupsd.conf to listen on the network interface and allow remote access from authorized clients.

# /etc/cups/cupsd.conf — Network print server configuration

# Listen on all interfaces (not just localhost)
Listen *:631

# Enable browsing so clients can discover printers
Browsing On
BrowseLocalProtocols dnssd

# Default authentication type
DefaultAuthType Basic

# Web interface access
WebInterface Yes

# Allow remote administration from the local subnet
<Location />
  Order allow,deny
  Allow @LOCAL
  Allow 192.168.1.0/24
</Location>

<Location /admin>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @LOCAL
  Allow 192.168.1.0/24
</Location>

<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @LOCAL
</Location>

# Share printers with network clients
<Policy default>
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job
         Purge-Jobs Set-Job-Attributes Create-Job-Subscription
         Renew-Subscription Cancel-Subscription Get-Notifications
         Reprocess-Job Cancel-Current-Job Suspend-Current-Job
         Resume-Job Cancel-My-Jobs Close-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
</Policy>
# Apply changes and restart CUPS
$ sudo systemctl restart cups

# Open firewall for IPP
$ sudo ufw allow 631/tcp

# Share a specific printer
$ sudo lpadmin -p OfficeHP -o printer-is-shared=true

# On client machines — discover and add the shared printer
$ lpinfo -v | grep ipp
$ sudo lpadmin -p RemoteHP -E 
    -v ipp://192.168.1.10:631/printers/OfficeHP 
    -m everywhere

# Or use the web interface on the client:
# https://print-server:631 -> Administration -> Find New Printers

# Access the web admin interface
# https://localhost:631/           — status page
# https://localhost:631/admin      — administration
# https://localhost:631/printers   — printer management
# https://localhost:631/jobs       — job management

# Useful troubleshooting commands
$ sudo tail -f /var/log/cups/error_log
$ sudo cupsctl --debug-logging     # Enable debug logging
$ sudo cupsctl --no-debug-logging  # Disable debug logging

# Check CUPS configuration for errors
$ sudo cupsd -t

The Allow @LOCAL directive permits access from any machine on the same subnet. For tighter control, specify explicit IP ranges. The web interface provides a user-friendly way to add printers, manage jobs, and configure settings without using the command line. Always use HTTPS (the default) when accessing the web interface remotely to protect authentication credentials.

Key Takeaways

  • CUPS uses the Internet Printing Protocol (IPP) on port 631 — an HTTP-based protocol that provides authentication, encryption, and comprehensive job management for both local and network printing.
  • The lpadmin command manages printers from the command line: -p names the printer, -v sets the device URI, -m everywhere enables driverless printing, and -E enables the printer immediately.
  • Printer classes group multiple printers under one name for automatic load balancing; cups-pdf creates a virtual PDF printer useful for testing, document archival, and paperless workflows.
  • Network sharing requires editing cupsd.conf to listen on network interfaces (Listen *:631), enable browsing, and set appropriate Allow directives in <Location> blocks for both the root path and /admin.
  • The CUPS web interface at https://localhost:631 provides graphical printer management, job monitoring, and server configuration; use cupsctl --debug-logging and /var/log/cups/error_log for troubleshooting.

What’s Next

You have completed the File Sharing & Print module. You now have the skills to deploy NFS for Unix/Linux environments, Samba for cross-platform file sharing and Active Directory services, vsftpd for secure FTP transfers, and CUPS for centralized print management. These services form the backbone of enterprise file and print infrastructure on Linux.

繁體中文

概述

  • 學習內容:如何在 Ubuntu 上安裝和設定 CUPS(通用 Unix 列印系統)作為網路列印伺服器。您將了解網際網路列印協定(IPP)、使用 lpadmin 管理印表機、建立印表機類別以實現負載平衡、設定 cups-pdf 進行虛擬 PDF 列印,以及設定 cupsd.conf 進行網路共享。
  • 先決條件:基本 Linux 系統管理、了解網路概念和防火牆設定
  • 預計閱讀時間:18 分鐘

IPP 協定與 CUPS 架構

CUPS 是 Linux 和 macOS 上的標準列印系統。它使用網際網路列印協定(IPP)——一種在連接埠 631 上執行的基於 HTTP 的協定——來管理列印工作、查詢印表機狀態,以及在用戶端和列印伺服器之間進行通訊。IPP 取代了較舊的協定如 LPD(行式印表機背景程式),並提供驗證、加密和工作管理等功能。

CUPS 架構由幾個元件組成。cupsd 背景程式監聽列印請求並管理列印佇列。後端透過 USB、平行埠、網路(IPP、LPD、SMB)或虛擬目的地處理與實體印表機的通訊。過濾器將文件格式(PDF、PostScript、點陣圖)轉換為印表機的原生語言。PPD 檔案(PostScript 印表機描述)描述印表機功能,如紙張大小、解析度和雙面列印支援。

# CUPS 架構概覽:
#
# 應用程式  -->  CUPS 用戶端 API  -->  cupsd(排程器)
#                                          |
#                   +----------------------+------------------------+
#                   |                      |                        |
#              過濾器鏈                PPD/驅動程式               後端
#           (格式轉換)           (印表機功能)            (輸出裝置)
#                   |                                           |
#              PDF -> PS -> 點陣圖                    USB / 網路 / PDF
#
# 關鍵檔案和目錄:
# /etc/cups/cupsd.conf     — 主要背景程式設定
# /etc/cups/printers.conf  — 印表機定義(自動產生)
# /etc/cups/ppd/           — 已安裝印表機的 PPD 檔案
# /var/spool/cups/         — 列印工作暫存目錄
# /var/log/cups/           — 日誌檔案(access_log、error_log)

安裝 CUPS 和使用 lpadmin 管理印表機

CUPS 通常預先安裝在 Ubuntu 桌面系統上,但伺服器安裝需要手動設定。lpadmin 命令是從命令列新增、修改和移除印表機的主要工具。

# 安裝 CUPS
$ sudo apt update
$ sudo apt install cups cups-client cups-bsd

# 啟動並啟用 CUPS 服務
$ sudo systemctl enable cups
$ sudo systemctl start cups

# 將使用者加入 lpadmin 群組以進行印表機管理
$ sudo usermod -aG lpadmin $USER

# 列出可用後端並探索網路印表機
$ lpinfo -v

# 列出可用的驅動程式/PPD
$ lpinfo -m | grep -i "laser"

# 使用 lpadmin 新增網路印表機
$ sudo lpadmin -p OfficeHP -E 
    -v ipp://192.168.1.50:631/ipp/print 
    -m everywhere 
    -D "辦公室 HP LaserJet" 
    -L "A 棟 101 室"

# 設定預設印表機選項
$ sudo lpadmin -p OfficeHP -o media=A4 -o sides=two-sided-long-edge

# 設定預設印表機
$ sudo lpadmin -d OfficeHP

# 停用/啟用印表機
$ sudo cupsdisable OfficeHP -r "維護中"
$ sudo cupsenable OfficeHP

# 移除印表機
$ sudo lpadmin -x OldPrinter

# 列印測試頁
$ lp -d OfficeHP /usr/share/cups/data/testprint

# 檢查印表機狀態
$ lpstat -p -d
$ lpstat -t

-E 旗標立即啟用印表機並接受工作。-m everywhere 選項使用 IPP Everywhere 無驅動程式列印,適用於大多數現代網路印表機,無需廠商專用的 PPD 檔案。對於較舊的印表機,您可能需要安裝特定的驅動程式套件並使用 -P 選項引用其 PPD 檔案。

印表機類別與 cups-pdf

印表機類別將多台實體印表機分組到單一邏輯名稱下,以實現負載平衡和冗餘。當工作傳送到類別時,CUPS 會將其路由到第一台可用的印表機。cups-pdf 套件建立一台虛擬印表機,產生 PDF 檔案而非實體輸出——對測試和文件歸檔非常有用。

# 建立印表機類別以實現負載平衡
$ sudo lpadmin -p Floor2-HP -E -v ipp://192.168.1.50:631/ipp/print -m everywhere
$ sudo lpadmin -p Floor2-Bro -E -v socket://192.168.1.51:9100 -m everywhere

# 將印表機加入類別
$ sudo lpadmin -c Floor2-Printers -p Floor2-HP
$ sudo lpadmin -c Floor2-Printers -p Floor2-Bro

# 設定類別為預設
$ sudo lpadmin -d Floor2-Printers

# 檢視類別成員
$ lpstat -c Floor2-Printers

# 安裝 cups-pdf 虛擬印表機
$ sudo apt install cups-pdf

# cups-pdf 自動設定——驗證它出現
$ lpstat -p PDF

# 列印到 PDF
$ lp -d PDF /etc/hostname

# PDF 輸出位置(每個使用者):
# /home/username/PDF/

# 設定 cups-pdf 行為
$ sudo nano /etc/cups/cups-pdf.conf
# Out       ${HOME}/PDF        — 輸出目錄
# Grp       lpadmin            — PDF 的群組擁有權
# UserUMask 0077               — 嚴格的檔案權限

# 工作管理命令
$ lpq                          # 檢視列印佇列
$ lpq -P OfficeHP              # 檢視特定印表機的佇列
$ lprm 123                     # 取消工作 123
$ cancel -a                    # 取消所有工作
$ lp -d OfficeHP -n 3 file.pdf # 列印 3 份

網頁管理和網路共享

CUPS 包含一個內建的網頁管理介面,可透過 https://localhost:631 存取。對於網路列印伺服器,您需要設定 cupsd.conf 以在網路介面上監聽並允許來自授權用戶端的遠端存取。

# /etc/cups/cupsd.conf — 網路列印伺服器設定

# 在所有介面上監聽(不僅是 localhost)
Listen *:631

# 啟用瀏覽讓用戶端可以發現印表機
Browsing On
BrowseLocalProtocols dnssd

# 預設驗證類型
DefaultAuthType Basic

# 網頁介面存取
WebInterface Yes

# 套用變更並重新啟動 CUPS
$ sudo systemctl restart cups

# 開啟 IPP 防火牆
$ sudo ufw allow 631/tcp

# 共享特定印表機
$ sudo lpadmin -p OfficeHP -o printer-is-shared=true

# 在用戶端機器上——探索並新增共享印表機
$ lpinfo -v | grep ipp
$ sudo lpadmin -p RemoteHP -E 
    -v ipp://192.168.1.10:631/printers/OfficeHP 
    -m everywhere

# 存取網頁管理介面
# https://localhost:631/           — 狀態頁面
# https://localhost:631/admin      — 管理
# https://localhost:631/printers   — 印表機管理
# https://localhost:631/jobs       — 工作管理

# 有用的疑難排解命令
$ sudo tail -f /var/log/cups/error_log
$ sudo cupsctl --debug-logging     # 啟用除錯日誌
$ sudo cupsctl --no-debug-logging  # 停用除錯日誌
$ sudo cupsd -t                    # 檢查設定錯誤

Allow @LOCAL 指令允許來自同一子網路上任何機器的存取。如需更嚴格的控制,請指定明確的 IP 範圍。網頁介面提供了使用者友善的方式來新增印表機、管理工作和設定設定,無需使用命令列。遠端存取網頁介面時務必使用 HTTPS(預設值)以保護驗證憑證。

重點摘要

  • CUPS 使用連接埠 631 上的網際網路列印協定(IPP)——一種基於 HTTP 的協定,為本機和網路列印提供驗證、加密和全面的工作管理。
  • lpadmin 命令從命令列管理印表機:-p 命名印表機、-v 設定裝置 URI、-m everywhere 啟用無驅動程式列印、-E 立即啟用印表機。
  • 印表機類別將多台印表機分組到一個名稱下以實現自動負載平衡;cups-pdf 建立虛擬 PDF 印表機,適用於測試、文件歸檔和無紙化工作流程。
  • 網路共享需要編輯 cupsd.conf 以在網路介面上監聽(Listen *:631)、啟用瀏覽,並在 <Location> 區塊中為根路徑和 /admin 設定適當的 Allow 指令。
  • CUPS 網頁介面位於 https://localhost:631,提供圖形化印表機管理、工作監控和伺服器設定;使用 cupsctl --debug-logging/var/log/cups/error_log 進行疑難排解。

下一步

您已完成「檔案共享與列印」模組。您現在具備了部署 NFS 用於 Unix/Linux 環境、Samba 用於跨平台檔案共享和 Active Directory 服務、vsftpd 用於安全 FTP 傳輸,以及 CUPS 用於集中式列印管理的技能。這些服務構成了 Linux 企業檔案和列印基礎設施的骨幹。

日本語

概要

  • 学習内容:Ubuntu に CUPS(Common Unix Printing System)をネットワークプリントサーバーとしてインストール・設定する方法。インターネット印刷プロトコル(IPP)の理解、lpadmin によるプリンター管理、負荷分散のためのプリンタークラス作成、cups-pdf による仮想 PDF 印刷の設定、cupsd.conf によるネットワーク共有の設定を学びます。
  • 前提条件:基本的な Linux システム管理、ネットワーキング概念とファイアウォール設定の理解
  • 推定読了時間:18分

IPP プロトコルと CUPS アーキテクチャ

CUPS は Linux と macOS の標準印刷システムです。インターネット印刷プロトコル(IPP)を使用します — ポート 631 で動作する HTTP ベースのプロトコルで、印刷ジョブの管理、プリンターステータスの照会、クライアントとプリントサーバー間の通信を行います。IPP は LPD(Line Printer Daemon)のような古いプロトコルを置き換え、認証、暗号化、ジョブ管理などの機能を提供します。

CUPS アーキテクチャはいくつかのコンポーネントで構成されています。cupsd デーモンは印刷リクエストをリッスンし、印刷キューを管理します。バックエンドは USB、パラレルポート、ネットワーク(IPP、LPD、SMB)、または仮想宛先を介して物理プリンターとの通信を処理します。フィルターはドキュメント形式(PDF、PostScript、ラスター)をプリンターのネイティブ言語に変換します。PPD ファイル(PostScript Printer Description)は用紙サイズ、解像度、両面印刷サポートなどのプリンター機能を記述します。

# CUPS アーキテクチャ概要:
#
# アプリケーション  -->  CUPS クライアント API  -->  cupsd(スケジューラ)
#                                                      |
#                   +----------------------------------+------------------+
#                   |                                  |                  |
#             フィルターチェーン                  PPD/ドライバー       バックエンド
#            (形式変換)                      (プリンター機能)    (出力デバイス)
#                   |                                                    |
#             PDF -> PS -> ラスター                          USB / ネットワーク / PDF
#
# 主要なファイルとディレクトリ:
# /etc/cups/cupsd.conf     — メインデーモン設定
# /etc/cups/printers.conf  — プリンター定義(自動生成)
# /etc/cups/ppd/           — インストール済みプリンターの PPD ファイル
# /var/spool/cups/         — 印刷ジョブスプールディレクトリ
# /var/log/cups/           — ログファイル(access_log、error_log)

CUPS のインストールと lpadmin によるプリンター管理

CUPS は通常 Ubuntu デスクトップシステムにプリインストールされていますが、サーバーインストールでは手動セットアップが必要です。lpadmin コマンドは、コマンドラインからプリンターの追加、変更、削除を行う主要なツールです。

# CUPS のインストール
$ sudo apt update
$ sudo apt install cups cups-client cups-bsd

# CUPS サービスの起動と有効化
$ sudo systemctl enable cups
$ sudo systemctl start cups

# プリンター管理のためユーザーを lpadmin グループに追加
$ sudo usermod -aG lpadmin $USER

# 利用可能なバックエンドの一覧とネットワークプリンターの検出
$ lpinfo -v

# 利用可能なドライバー/PPD の一覧
$ lpinfo -m | grep -i "laser"

# lpadmin でネットワークプリンターを追加
$ sudo lpadmin -p OfficeHP -E 
    -v ipp://192.168.1.50:631/ipp/print 
    -m everywhere 
    -D "オフィス HP LaserJet" 
    -L "A棟 101号室"

# デフォルトプリンターオプションの設定
$ sudo lpadmin -p OfficeHP -o media=A4 -o sides=two-sided-long-edge

# デフォルトプリンターの設定
$ sudo lpadmin -d OfficeHP

# プリンターの無効化/有効化
$ sudo cupsdisable OfficeHP -r "メンテナンス中"
$ sudo cupsenable OfficeHP

# プリンターの削除
$ sudo lpadmin -x OldPrinter

# テストページの印刷
$ lp -d OfficeHP /usr/share/cups/data/testprint

# プリンターステータスの確認
$ lpstat -p -d
$ lpstat -t

-E フラグはプリンターを有効にし、即座にジョブを受け付けます。-m everywhere オプションは IPP Everywhere ドライバーレス印刷を使用し、ベンダー固有の PPD ファイルなしでほとんどの最新ネットワークプリンターで動作します。古いプリンターの場合は、特定のドライバーパッケージをインストールし、-P オプションで PPD ファイルを参照する必要があるかもしれません。

プリンタークラスと cups-pdf

プリンタークラスは、負荷分散と冗長性のために複数の物理プリンターを単一の論理名でグループ化します。ジョブがクラスに送信されると、CUPS はそれを最初の利用可能なプリンターにルーティングします。cups-pdf パッケージは、物理出力の代わりに PDF ファイルを生成する仮想プリンターを作成します — テストとドキュメントアーカイブに非常に有用です。

# 負荷分散用プリンタークラスの作成
$ sudo lpadmin -p Floor2-HP -E -v ipp://192.168.1.50:631/ipp/print -m everywhere
$ sudo lpadmin -p Floor2-Bro -E -v socket://192.168.1.51:9100 -m everywhere

# プリンターをクラスに追加
$ sudo lpadmin -c Floor2-Printers -p Floor2-HP
$ sudo lpadmin -c Floor2-Printers -p Floor2-Bro

# クラスをデフォルトに設定
$ sudo lpadmin -d Floor2-Printers

# クラスメンバーの表示
$ lpstat -c Floor2-Printers

# cups-pdf 仮想プリンターのインストール
$ sudo apt install cups-pdf

# cups-pdf は自動設定 — 表示されることを確認
$ lpstat -p PDF

# PDF に印刷
$ lp -d PDF /etc/hostname

# PDF 出力場所(ユーザーごと):
# /home/username/PDF/

# cups-pdf の動作設定
$ sudo nano /etc/cups/cups-pdf.conf
# Out       ${HOME}/PDF        — 出力ディレクトリ
# Grp       lpadmin            — PDF のグループ所有権
# UserUMask 0077               — 制限付きファイル権限

# ジョブ管理コマンド
$ lpq                          # 印刷キューの表示
$ lpq -P OfficeHP              # 特定プリンターのキュー表示
$ lprm 123                     # ジョブ 123 のキャンセル
$ cancel -a                    # すべてのジョブをキャンセル
$ lp -d OfficeHP -n 3 file.pdf # 3部印刷

Web 管理とネットワーク共有

CUPS には https://localhost:631 でアクセスできる組み込みの Web 管理インターフェースが含まれています。ネットワークプリントサーバーの場合、cupsd.conf を設定してネットワークインターフェースでリッスンし、認可されたクライアントからのリモートアクセスを許可する必要があります。

# /etc/cups/cupsd.conf — ネットワークプリントサーバー設定

# すべてのインターフェースでリッスン(localhost だけでなく)
Listen *:631

# クライアントがプリンターを検出できるようブラウジングを有効化
Browsing On
BrowseLocalProtocols dnssd

# デフォルト認証タイプ
DefaultAuthType Basic

# Web インターフェースアクセス
WebInterface Yes

# 変更を適用して CUPS を再起動
$ sudo systemctl restart cups

# IPP 用ファイアウォールを開放
$ sudo ufw allow 631/tcp

# 特定のプリンターを共有
$ sudo lpadmin -p OfficeHP -o printer-is-shared=true

# クライアントマシンで — 共有プリンターを検出して追加
$ lpinfo -v | grep ipp
$ sudo lpadmin -p RemoteHP -E 
    -v ipp://192.168.1.10:631/printers/OfficeHP 
    -m everywhere

# Web 管理インターフェースへのアクセス
# https://localhost:631/           — ステータスページ
# https://localhost:631/admin      — 管理
# https://localhost:631/printers   — プリンター管理
# https://localhost:631/jobs       — ジョブ管理

# トラブルシューティングコマンド
$ sudo tail -f /var/log/cups/error_log
$ sudo cupsctl --debug-logging     # デバッグログの有効化
$ sudo cupsctl --no-debug-logging  # デバッグログの無効化
$ sudo cupsd -t                    # 設定エラーの確認

Allow @LOCAL ディレクティブは同じサブネット上の任意のマシンからのアクセスを許可します。より厳密な制御には、明示的な IP 範囲を指定してください。Web インターフェースはコマンドラインを使用せずにプリンターの追加、ジョブの管理、設定の構成を行うユーザーフレンドリーな方法を提供します。認証資格情報を保護するため、リモートから Web インターフェースにアクセスする際は常に HTTPS(デフォルト)を使用してください。

重要ポイント

  • CUPS はポート 631 のインターネット印刷プロトコル(IPP)を使用します — ローカルおよびネットワーク印刷の認証、暗号化、包括的なジョブ管理を提供する HTTP ベースのプロトコルです。
  • lpadmin コマンドはコマンドラインからプリンターを管理します:-p でプリンター名、-v でデバイス URI、-m everywhere でドライバーレス印刷を有効化、-E で即座にプリンターを有効化します。
  • プリンタークラスは自動負荷分散のために複数のプリンターを 1 つの名前でグループ化します。cups-pdf はテスト、ドキュメントアーカイブ、ペーパーレスワークフローに便利な仮想 PDF プリンターを作成します。
  • ネットワーク共有には cupsd.conf の編集が必要です — ネットワークインターフェースでのリッスン(Listen *:631)、ブラウジングの有効化、ルートパスと /admin<Location> ブロックでの適切な Allow ディレクティブの設定。
  • https://localhost:631 の CUPS Web インターフェースはグラフィカルなプリンター管理、ジョブ監視、サーバー設定を提供します。トラブルシューティングには cupsctl --debug-logging/var/log/cups/error_log を使用します。

次のステップ

「ファイル共有と印刷」モジュールが完了しました。Unix/Linux 環境向けの NFS、クロスプラットフォームファイル共有と Active Directory サービス向けの Samba、安全な FTP 転送向けの vsftpd、集中印刷管理向けの CUPS を展開するスキルを習得しました。これらのサービスは Linux 上のエンタープライズファイルおよび印刷インフラストラクチャの基盤を形成します。

You Missed