Frequently Asked Questions – CUPS.org

Adding filetypes and filters

Adding a new file type or filter is fairly straight-forward. Rather
than adding the new type and filter to the mime.types and
mime.convs files which are overwritten when you upgrade to a
new version of CUPS, you simple need to create new files with
.types and .convs extensions in the
/etc/cups directory. We recommend that you use the product
or format name, e.g.:

    myproduct.types
    myproduct.convs
    

If you are providing a filter for a common file format or printer,
add the company or author name:

    acme-msword.types
    acme.msword.convs
    

This will help to prevent name collisions if you install many
different file types and filters.

Once you choose the names for these files, create them using your
favorite text editor as described earlier in this chapter. Once you
have created the files, restart the cupsd process as
described earlier in “Restarting the CUPS Server”.

Changing the server configuration

The /etc/cups/cupsd.conf file contains configuration
directives that control how the server functions. Each directive
is listed on a line by itself followed by its value. Comments are
introduced using the number sign (“#”) character at the beginning of a
line. Since the server configuration file consists of plain text, you
can use your favorite text editor to make changes to it.

Cli tools

See CUPS local documentation for more tips on the command-line tools.

Note: Command-line switches cannot be grouped.

Use SNMP to find a URI:

$ /usr/lib/cups/backend/snmp ip_address

Columbia appletalk package (cap)

Because the CAP LaserWriter server (lwsrv(8)) does
not support specification of PPD files, we do not recommend that you
use CAP with CUPS. However, you can run the lpsrv program
for limited printing with the command:

    lwsrv -n "Name" -p printer -a /usr/lib/adicts -f /usr/lib/LW Fonts
    

where Name is the name you want to use when sharing the
printer, and printer is the name of the CUPS print queue.

Configuring the ip address using arp

The easiest way to set the IP address of a network device is to use
the arp(8) command. The arp sends an Address
Resolution Protocol (“ARP”) packet to the specified Ethernet MAC address,
setting the network device’s IP address:

Configuring the ip address using bootp

The BOOTP protocol is used when you need to provide additional information
such as the location of a configuration file to the network interface. Using
the standard bootpd(8) program supplied with UNIX you simply need to
add a line to the /etc/bootptab file; for IRIX:

    myprinter 08:00:69:00:12:34 192.0.2.2 myprinter.boot

Newer versions of bootpd use a different format:

    myprinter:ha=080069001234:ip=192.0.2.2:t144=myprinter.boot

The myprinter.boot file resides in the /usr/local/boot
directory by default. If you do not need to provide a boot file you may leave
the last part of the line blank.

NOTE:

Some versions of UNIX do not enable the BOOTP service by
default. The /etc/inetd.conf usually contains a
line for the BOOTP service that can be uncommented if
needed.

Configuring the ip address using rarp

The most flexible way to remotely assign IP addresses under UNIX
is through the Reverse Address Resolution Protocol (“RARP”). RARP
allows a network device to request an IP address using its Ethernet
MAC address, and one or more RARP servers on the network will
respond with an ARP packet with the IP address the device can use.

RARP should be used when you have to manage many printers or print
servers, or when you have a network device that does not remember its
IP address after a power cycle. If you just have a single printer or
print server, the arp command is the way to go.

Some UNIX operating systems use a program called
rarpd(8) to manage RARP. Others, like Linux, support this
protocol in the kernel. For systems that provide the rarpd
program you will need to start it before RARP lookups will work:

Under IRIX you can enable this functionality by default using:

Connection interfaces

Additional steps for printer detection are listed below for various connection interfaces.

Default paper size

cups is built with libpaper support and libpaper defaults to the Letter paper size (called PageSize in lpoptions).

To avoid having to change the paper size for each print queue you add, edit/etc/papersize and set your system default paper size. See papersize(5).

Example

    PrintcapGUI /usr/bin/glpoptions
    

Examples

    LogLevel none
    LogLevel emerg
    LogLevel alert
    LogLevel crit
    LogLevel error
    LogLevel warn
    LogLevel notice
    LogLevel info
    LogLevel debug
    LogLevel debug2
    

Exporting printer drivers

You can optionally export printer drivers from your CUPS
server using the cupsaddsmb command and the SAMBA
2.2.0 or higher software.

Gutenprint

The Gutenprint project provides drivers for Canon, Epson, Lexmark, Sony, Olympus, and PCL printers for use with CUPS and GIMP.

Install gutenprint and foomatic-db-gutenprint-ppds.

Implicit classes

A noted earlier, implicit classes are created automatically from the
available network printers and classes. To disable this functionality,
set the ImplicitClasses
directive to Off in the cupsd.conf file. You
will find more information on doing this in
Chapter 6, “Printing System
Management”.

Installation

Install the cups package.

Load balancing and failsafe operation

When using server polling or broadcasting, CUPS clients can
automatically merge identical printers on multiple servers into a
single implicit class queue. Clients assume that printers with
the same name on multiple servers are in fact the same printer or type
of printer being served by multiple machines.

Log files

By default, all logs are sent to files in /var/log/cups/. By changing the values of the AccessLog, ErrorLog, and PageLog directives in /etc/cups/cups-files.conf to syslog, CUPS can be made to log to the systemd journal instead. See Fedora:Changes/CupsJournalLogging for information on the original proposed change.

Managing printers from the web

The Web interface is located at:

From there you can perform all printer management tasks with a few
simple mouse clicks.

Mime.convs

The mime.convs file defines all of the filter programs that
are known to the system. Each line consists of:

Mime.types

The mime.types file defines the known file types. Each line
of the file starts with the MIME type and may be followed by one or
more file type recognition rules. For example, the
text/html file type is defined as:

    text/html       html htm 
                    printable(0,1024)   
                    (string(0,"<HTML>") string(0,"<!DOCTYPE"))
    

The first two rules say that any file with an extension of
.html or .htm is a HTML file. The third rule
says that any file whose first 1024 characters are printable text and
starts with the strings <HTML> or
<!DOCTYPE is a HTML file as well.

The first two rules deal solely with the name of the file being
typed. This is useful when the original filename is known, however for
print files the server doesn’t have a filename to work with. The third
rule takes care of this possibility and automatically figures out the
file type based upon the contents of the file instead.

The available tests are:

  • ( expr ) – Parenthesis for expression grouping
  • – Logical AND
  • , or whitespace – Logical OR
  • ! – Logical NOT
  • match("pattern") – Pattern match on filename
  • extension – Pattern match on “*.extension”
  • ascii(offset,length) – True if bytes are valid
    printable ASCII (CR, NL, TAB, BS, 32-126)

  • printable(offset,length) – True if bytes are
    printable 8-bit chars (CR, NL, TAB, BS, 32-126, 160-254)

  • string(offset,"string") – True if bytes are
    identical to string

  • contains(offset,range,"string") – True if the
    range of bytes contains the string

  • char(offset,value) – True if byte is identical
  • short(offset,value) – True if 16-bit integer
    is identical (network or “big-endian” byte order)

  • int(offset,value) – True if 32-bit integer is
    identical (network or “big-endian” byte order)

  • locale("string") – True if current locale
    matches string

All numeric values can be in decimal (123), octal (0123), or hexadecimal
(0x123) as desired.

Strings can be in quotes, all by themselves, as a string
of hexadecimal values, or some combination:

    "string"
    'string'
    string
    <737472696e67>
    <7374>ring
    

As shown in the text/html example, rules can continue on
multiple lines using the backslash () character. A more complex example is
the image/jpeg rules:

    image/jpeg      jpeg jpg jpe string(0,<FFD8FF>) &&
                    (char(3,0xe0) char(3,0xe1) char(3,0xe2) char(3,0xe3)
                     char(3,0xe4) char(3,0xe5) char(3,0xe6) char(3,0xe7)
                     char(3,0xe8) char(3,0xe9) char(3,0xea) char(3,0xeb)
                     char(3,0xec) char(3,0xed) char(3,0xee) char(3,0xef))
    

This rule states that any file with an extension of
.jpeg, .jpg, or .jpe is a JPEG file.
In addition, any file starting with the hexadecimal string
<FFD8FF> (JPEG Start-Of-Image) followed by a
character between and including 0xe0 and 0xef
(JPEG APPn markers) is also a JPEG file.

Netatalk

To use your system as a print server for Mac OS clients,
configure each printer in the papd.conf file, specifying the
corresponding PPD file in the /etc/cups/ppd directory for
each printer. For a printer named MyPrinter the entry
would look like:

    Printer Description:MyPrinter@MyServer:
            :pr=|/usr/bin/lp -d MyPrinter:
            :op=daemon:
            :pd=/etc/cups/ppd/MyPrinter.ppd:
    

Openprinting cups filters

The Linux Foundation’s OpenPrinting workgroup provides cups-filters. Those are backends, filters, and other binaries that were once part of CUPS but have been dropped from the project. They are available in the cups-filters package that is a dependency of cups.

Parallel port

To use a parallel port printer, the lp, parport and parport_pckernel modules are required.

# dmesg | grep -i parport
parport0: Printer, Hewlett-Packard HP LaserJet 2100 Series
lp0: using parport0 (polling)

Printer drivers and ppd files

Most CUPS printer drivers utilize one or more printer-specific filters
and a PPD file for each printer model. Printer driver filters are registered
via the PPD file using cupsFilter attributes:

    *cupsFilter: "application/vnd.cups-raster 0 rastertohp"
    

The filter is specified using the source file type only; the destination
file type is assumed to be printer/name – suitable for sending
to the printer.

Printer uri

Listed below are additional steps to manually generate the URI if required. Some printers or drivers may need a special URI as described in CUPS/Printer-specific problems.

Printing from lpd clients

CUPS supports limited functionality for LPD-based clients. With LPD you can
print files to specific printers, list the queue status, and so forth. However,
the automatic client configuration and printer options are not supported by
the LPD protocol, so you must manually configure each client for the printers
it needs to access.

The cups-lpd(8) program provides support for LPD
clients and can be used from either the inetd(8) or
xinetd(8) programs. Add the following line to the
/etc/inetd.conf file to enable LPD support on your
server through the inetd program:

    printer stream tcp nowait lp /usr/lib/cups/daemon/cups-lpd cups-lpd
    

The path to the cups-lpd may vary depending on your
installation.

Once you have added this line, send the inetd
process a HUP signal or reboot the system:

    killall -HUP inetd ENTER [IRIX and some versions of Linux]
    kill -HUP pid ENTER [Others]reboot ENTER [For all systems if the HUP signal fails]

If you are using the xinetd program, create a
file named /etc/xinetd.d/printer containing the
following lines:

The xinetd program automatically reads the new
configuration file and enables LPD printing support.

Warning:

cups-lpd currently does not perform any
access control based on the settings in
cupsd.conf or in the hosts.allow
or hosts.deny files used by TCP wrappers.
Therefore, running cups-lpd on your server
will allow any computer on your network (and perhaps the
entire Internet) to print to your server.

While xinetd has built-in access control
support, you should use the TCP wrappers package with
inetd to limit access to only those
computers that should be able to print through your
server.

Printing to mac os servers

CUPS currently does not provide a backend to communicate with a Mac OS
server. However, you can write and install a short shell script
in the /usr/lib/cups/backend directory that sends a print file
using the appropriate command. The following is a short script that will
run the papif command provided with CAP.

After copying this script to /usr/lib/cups/backend/cap,
specify a device URI of cap://server/printer to use this
backend with a print queue.

Server directives

The cupsd.conf file contains many directives that
determine how the server operates:

Socket activation

cups provides a cups.socket unit. If cups.socket is enabled (and cups.service is disabled), systemd will not start CUPS immediately; it will just listen to the appropriate sockets.

Starting and stopping printers

The enable and disable commands start and stop
printer queues, respectively:

    /usr/bin/enable printer ENTER/usr/bin/disable printer ENTER

Printers that are disabled may still accept jobs for printing, but won’t
actually print any files until they are restarted. This is useful if the
printer malfunctions and you need time to correct the problem. Any queued
jobs are printed after the printer is enabled (started).

The basics

Each printer queue has a name associated with it; the printer name
must start with a letter and can contain up to 127 letters, numbers,
and the underscore (_). Case is not significant, e.g. “PRINTER”, “Printer”,
and “printer” are considered to be the same name.

Printer queues also have a device associated with them. The device can be
a parallel port, a network interface, and so forth. Devices within CUPS use
Uniform Resource Identifiers (“URIs”) which are a more general form of
Uniform Resource Locators (“URLs”) that are used in your web browser. For
example, the first parallel port in Linux usually uses a device URI of
parallel:/dev/lp1.

You can see a complete list of supported devices by running the
lpinfo(8) command:

The -v option specifies that you want a list of available
devices. The first word in each line is the type of device (direct, file,
network, or serial) and is followed by the device URI or method name for
that device. File devices have device URIs of the form
file:/directory/filename while network devices use the more
familiar method://server or method://server/path
format.

The error_log file

The error_log file lists messages from the scheduler (errors,
warnings, etc.):

    level date-time message
    
    I [20/May/1999:19:18:28  0000] Job 1 queued on 'DeskJet' by 'mike'.
    I [20/May/1999:19:21:02  0000] Job 2 queued on 'DeskJet' by 'mike'.
    I [20/May/1999:19:22:24  0000] Job 2 was cancelled by 'mike'.
    

The level field contains the type of message:

  • E – An error occurred.
  • W – The server was unable to perform some action.
  • I – Informational message.
  • D – Debugging message.

The date-time field contains the date and time of when the page
started printing. The format of this field is identical to the data-time
field in the access_log file.

The message fields contains a free-form textual message.

The page_log file

The page_log file lists each page that is sent to a printer.
Each line contains the following information:

The printer field contains the name of the printer that
printed the page. If you send a job to a printer class, this field will
contain the name of the printer that was assigned the job.

Troubleshooting

See CUPS/Troubleshooting.

Verifying the printer connection

To test that the IP address has been successfully assigned and that the
printer is properly connected to your LAN, type:

If the connection is working properly you will see something like:

    ping myprinter ENTER
    PING myprinter (192.0.2.2): 56 data bytes
    64 bytes from 192.0.2.2: icmp_seq=0 ttl=15 time=5 ms
    64 bytes from 192.0.2.2: icmp_seq=1 ttl=15 time=3 ms
    64 bytes from 192.0.2.2: icmp_seq=2 ttl=15 time=3 ms
    64 bytes from 192.0.2.2: icmp_seq=3 ttl=15 time=3 ms
    

If not, verify that the printer or print server is connected to the
LAN, it is powered on, the LAN cabling is good, and the IP address is
set correctly. You can usually see the current IP address and network
status by printing a configuration or test page on the device.

Xinet ka/spool

To use your system as a print server for Mac OS clients,
configure each printer using a papserver(8) in the
/usr/adm/appletalk/services file, specifying the
corresponding PPD file in the /etc/cups/ppd directory for
each printer. For a printer named MyPrinter the entry
would look like:

    /usr/etc/appletalk/papserver -I -L -P /etc/cups/ppd/MyPrinter.ppd 
    "Printer Description" MyPrinter
    
NOTE:

Enter the text above on a single line without the backslash ()
character.

Печать pdf файла из командной строки в linux

Для печати PDF файла из командной строки можно воспользоваться стандартной командой печати, приведенной выше:

Подключение принтера в cups

Для подключения и настройки принтера в CUPS проще всего воспользоваться WEB-интерфейсом, который доступен после установки.

Проверка печати в linux

Выполнить проверку печати можно, как минимум, двумя способами:

Удаленный доступ к web-интерфейсу cups

Настройка доступа к интерфейсу CUPS осуществляется в конфигурационном файле: /etc/cups/cupsd.conf.

Но проще всего выполнить настройку параметров удаленного доступа к WEB-интерфейсу CUPS с помощью следующей команды:

Эта команда автоматически обновит конфигурационный файл /etc/cups/cupsd.conf, а оригинальный файл будет переименован в cupsd.conf.O.

Универсальная система печати unix на freebsd

После того, как система CUPS была установлена и сконфигурирована, системный администратор может начать конфигурирование локальных принтеров, подключенных к серверу печати CUPS. Эта часть процесса очень похожа, если не идентична настройке принтеров CUPS в других UNIX®-подобных операционных системах, таких как дистрибутивы Linux®.

Основным способом управления и администрирования сервера CUPS является веб-интерфейс, на который можно попасть запустив веб-браузер и набрав http://localhost:631 в его адресной строке. Если сервер CUPS находится на другой машине в сети, замените localhost на IP адрес сервера. Веб-интерфейс CUPS достаточно очевиден, там есть разделы для управления принтерами и заданиями на печать, авторизацией пользователей и т.п. Кроме того, в правой части страницы администрирования есть несколько флажков (check-box), дающих удобный доступ к часто меняемым установкам, таким как разрешение публичного доступа к подключенным к системе принтерам, предоставление удаленного управления сервером CUPS, изменение уровня доступа пользователей к принтерам и их заданиям на печать.

Добавление принтера в общем такое же простое, как нажатие “Add Printer” на странице администрирования веб-интерфейса сервера CUPS или как нажатие одной из кнопок “New Printers Found” на той же странице администрирования. Когда перед вами предстанет выпадающий список “Device”, просто выберите требуемый локально подключенный принтер, а дальше следуйте подсказкам интерфейса. В случае если были установлены порты или пакеты print/gutenprint-cups или print/hplip, как указывалось выше, дополнительные драйвера печати будут доступны на последующих страницах, что может обеспечить большую надежность и расширенные возможности.

Установка cups

CUPS может быть установлен из репозитария операционной системы CentOS/RedHat стандартными средствами:

После завершения установки запустим сервер CUPS и добавим его в автозагрузку:

Сразу же после установки сервер CUPS готов к работе, однако для печати необходимо подключить принтер, на который будет осуществляться вывод, и выполнить его настройку.

Похожее:  Datacol — универсальный парсер различной информации в Интернете | Сайтовед

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *