最後更新: 2016-03-12



CUPS - Common UNIX Print System


The print spooler running on the print server box can be reached over the LPD protocol on port 515.

The print spooler running on the print server box can also be reached over the IPP protocol on port 631.

The printer connected to the print server box can be accessed directly via TCP sockets on port 9100.


查看 samba 是否 support cups


ldd /usr/sbin/smbd | grep cups => /usr/lib/ (0xf7650000)


smbd -b | grep CUPS



RAW printer


content is sent unmodified to the device

=> don't use filters or drivers on the backend

clients were expected to prepare the print job file that is ready to be sent to the printing device.

In this case, a native (vendor-supplied) Windows printer driver needs to be installed on each and every client for the target device.




Configure: /etc/cups/cupsd.conf

# web panel 的 port
Port 631

Listen /var/run/cups/cups.sock

# Enable printer sharing and shared printers.
# * Browsing will only work if Avahi is running before cupsd is started
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseAddress 192.168.0.*:631

# Disable SSL
DefaultEncryption Never


<Location />
  # Allow shared printing and remote administration...
  Allow all
  Order allow,deny
<Location /admin>
  # Allow remote administration...
  Allow all
  Order allow,deny
<Location /admin/conf>
  #AuthType Default
  #Require user @SYSTEM
  Allow all
  Order allow,deny

service cups restart


Add Printer


/etc/cups/printers.conf   <-   每個 printer 一個 configure file



<DefaultPrinter ml1640-raw>
Info ml1640-raw
DeviceURI file:///dev/usb/lp0
State Idle
StateTime 1333959614
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy abort-job

# socket

<Printer Samsung_SCX-3400_Series>
UUID urn:uuid:70af9717-85c8-34c3-5095-76040d935c0c
Info Samsung SCX-3400 Series
MakeModel Samsung SCX-3400 Series
DeviceURI socket://
PPDTimeStamp *
State Idle
StateTime 1462418620
Type 4164
Accepting Yes
Shared Yes
ColorManaged Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job


User ACL

# None, Basic, BasicDigest, Digest, Negotiate
AuthType None

Require user user-name-list

# Require the Owner of a Job or Subscription    
Require user @OWNER

# Require an Administrative User    
Require user @SYSTEM

# Require Member of Group "foogroup"    
Require user @foogroup

# Require "john" or "mary"    
Require user john mary


Client Command


apt-get install cups-client

/usr/bin/lpstat           # show available devices or drivers

/usr/sbin/lpadmin         # configure cups printers and classes
/usr/sbin/lpinfo          # lpinfo - show available devices or drivers
/usr/sbin/cupsaccept      # accept/reject jobs sent to a destination
/usr/sbin/cupsenable      # stop/start printers and classes


cupstestppd Samsung_SCX-3400_Series.ppd

Samsung_SCX-3400_Series.ppd: PASS
        WARN    Size "Folio" should be the Adobe standard name "FanFoldGermanLegal".
        WARN    Size "JB5" should be the Adobe standard name "B5".
        WARN    Size "B5-ISO" should be the Adobe standard name "ISOB5".
        WARN    Size "COM10" should be the Adobe standard name "Env10".
        WARN    Size "Monarch" should be the Adobe standard name "EnvMonarch".
        WARN    Size "DL" should be the Adobe standard name "EnvDL".
        WARN    Size "C5" should be the Adobe standard name "EnvC5".
        WARN    Size "Oficio_S" should be "8.5x13.5".
        WARN    Size "PCard4x6" should be the Adobe standard name "4x6".
        WARN    DefaultCompression has no corresponding options.

# lists the available devices or drivers known to the CUPS server.


(-m) lists the available drivers

uld-samsung/Samsung_SCX-3400_Series.ppd Samsung SCX-3400 Series

(-v) lists the available devices

serial serial:/dev/ttyS0?baud=115200
network socket://
network socket://
network ipp://
network ipp://



-p            # a list of printers

printer Samsung_SCX-3400_Series is idle.  enabled since Thursday, May 05, 2016 AM11:23:40 HKT

-d            # Shows the current default destination

no system default destination

# 當有 print job 時

Samsung_SCX-3400_Series-1 root              1024   Thursday, May 05, 2016 AM11:44:45 HKT

-r     # Shows whether the CUPS server is running.

scheduler is running

-s     # summary

system default destination: Samsung_SCX-3400_Series
device for Samsung_SCX-3400_Series: socket://


Setting the Default Printer

lpoptions -d Samsung_SCX-3400_Series

# check

lpstat -d

system default destination: Samsung_SCX-3400_Series

Turning Off Text Wrapping

lp -o nowrap filename

Raw or Unfiltered Output

lp -o raw filename


ppd file





連 printer 的方法



Sharing via IPP


* native protocol for CUPS

* Windows client 連去 Linux print server 的最好方式

* standard printer protocol based on HTTP

IPP uses the traditional client-server model, with clients sending IPP request messages with the MIME media type "application/ipp" in HTTP POST requests to an IPP printer. IPP request messages consist of key/value pairs using a custom binary encoding followed by an "end of attributes" tag and any document data required for the request. The IPP response is sent back to the client in the HTTP POST response, again using the "application/ipp" MIME media type.

IPP is implemented using the Hypertext Transfer Protocol (HTTP) and inherits all of the HTTP streaming and security features.

For example
SSL/TLS protocol-layer

Among other things, IPP allows a client to:

    query a printer's capabilities
    submit print jobs to a printer
    query the status of a printer
    query the status of one or more print jobs
    cancel previously submitted jobs

IPP uses TCP with port 631 as its well-known port.

IPP implementations such as CUPS also use UDP with port 631 for IPP printer discovery.


Browsing On
BrowseOrder allow,deny
BrowseAllow all

Test Service

By default, a CUPS network server broadcasts its queue every thirty seconds via the UDP port 631. Thus, the following command can be used to test if a CUPS network server exists in the network:

netcat -u -l -p 631 & PID=$! ; sleep 40 ; kill $PID

The following command tests whether cupsd can be reached via TCP on port 631 of host:

netcat -z <host> 631 && echo ok || echo failed

If you have other clients and want to print in PostScript from them, often the printer driver can use a "PPD" (PostScript Printer Description file) for complete support of the printers' features.

You can download the PPD files for any configured printer from the CUPS server:

   http://<host name>:631/printers/<printer queue name>.ppd


   https://<host name>:443/printers/<printer queue name>.ppd

Client add printer by (Windows)

An HP JetDirect printer requires

socket://hostname   <--   Default port: 9100

An IPP printer requires




Sharing via Samba

    # 設定 printcap 的位置, Default: "printcap = /etc/printcap"
    # CUPS does not need a printcap file
    # 因為 cupsd.conf 會設定 printer
    # cups => uses the CUPS API to list printers, submit jobs, query queues, and so on.
    printcap = cups

    # how printer status information is interpreted on your system.
    # ** This option can be set on a per printer basis. **
    printing = CUPS

    # automatically share all printers available in the backend
    load printers = yes

    comment=All Printers
    guest ok=yes
    create mode=0700
    write list=@adm root ti


# '|' separates aliases of a printer

print1|My Printer 1
print2|My Printer 2
print3|My Printer 3

Sharing via LPD

* The software running on the sender(pc) and recipient(printer) must support the respective protocol.

* With this method, no print job is sent to a remote queue

An LPD printer server requires syntax lpd://hostname/queue syntax. <-- lpq 可以看到 Q 名

一定要填 Q 名, 否則會

May  6 11:59:31 ubuntu cups-lpd[10587]: Connection from (IPv4
May  6 11:59:31 ubuntu cups-lpd[10587]: Receive print job for
May  6 11:59:31 ubuntu cups-lpd[10587]: Unable to find "" in list of printers!
May  6 11:59:31 ubuntu cups-lpd[10587]: Unable to get printer information for ""
May  6 11:59:31 ubuntu cups-lpd[10587]: Closing connection


Standard TCP/IP Port

Protocol: raw

Port: 9100




# U14

apt-get install cups-bsd

# Centos7

yum install cups cups-client cups-lpd


/usr/bin/lpq        # show printer queue status
/usr/bin/lpr        # print files
/usr/bin/lprm        # cancel print jobs
/usr/sbin/lpc        # line printer control program


# 在有野 print 時

Samsung_SCX-3400_Series is ready and printing
Rank    Owner   Job     File(s)                         Total Size
active  unknown 4       unknown                         23552 bytes


lpc status

        printer is on device 'socket' speed -1
        queuing is enabled
        printing is enabled
        no entries
        daemon present

Daemon: cups-lpd

port: 515

cups-lpd - receive print jobs and report printer status to lpd clients

cups-lpd  is  the  CUPS  Line  Printer  Daemon ("LPD") mini-server that
       supports legacy client systems that use the LPD protocol. cups-lpd does
       not  act  as a standalone network daemon but instead operates using the
       Internet "super-server" inetd(8) or xinetd(8).

Program: /usr/lib/cups/daemon/cups-lpd


service printer
    socket_type = stream
    protocol = tcp
    wait = no
    user = lp
    group = sys
    passenv =
    server = /usr/lib/cups/daemon/cups-lpd
    server_args = -o document-format=application/octet-stream


* cups-lpd currently does not perform any access control based on the settings in cupsd.conf(5) or in the hosts.allow(5) or hosts.deny(5)

* 要用 xinetd 的 ACL





queue named: color

lp -d color filename

Checking the Status

# shows all active print jobs in the form of a queuename-jobnumber listing

lpstat -o

Removing Jobs from the Queue

lprm -P queuename job_number


USB Ports


# this printer is able to print ASCII text directly
echo -en "\rHello\r\f" >/dev/usb/lp0

# If this does not display any information
cat /proc/bus/usb/devices




filtering process: the conversion of the original data to printer-specific data

Unix Filter enables you to use image and document manipulation features such as duplexing and finishing in Unix Platform.

print server boxes: only receive printer-specific data and forward it to the printer
(which is equipped with both a TCP/IP network link and a local printer port.)

Workstation -> Print Server -> Print Server Box -> Printer

Print via CUPS Network Server:

    no filtering (as this is usually done on the CUPS network server)

Print directly on a network printer or using a print server box:



Window Client



    [1] use a PS driver on Windows and a specific driver in CUPS
    [2] use a specific driver in Windows and the Raw (which actually means transparent) driver in CUPS


Built-in MS Publisher Imagesetter

"Add Printer"
"Connect to a printer on the Internet..."
URL for your printer queue (e.g. http://rock:631/printers/Epson).  
When prompted for a driver select a Manufacturer of "Generic" and the Printer "MS Publisher Imagesetter".

Adobe Driver

To use the Adobe driver simply run the installer, select "Network Printer", enter the URL of your printer queue (should be of the form http://hostname:631/printers/PrinterName), and then select "yes" when prompted.  You can either use the "Generic PostScript Printer" option, or "Browse" for the printer specific PPD file created by CUPS (located in /etc/cups/ppd/PrinterQueueName.ppd on the Linux machine).





Creative Commons license icon Creative Commons license icon