Practical settings of cups printing service in Linux

Source: Internet
Author: User
In Linux, the cups printing service is set in practice-Linux Enterprise Application-Linux server application information. The following is a detailed description. After studying the printing settings of cups for some time, I found that the information on the Internet was not clear, so I decided to record my settings for your future reference.
My LINUX is redhat enterprise 3
In this article, assume that the Host Name of the CUPS printing server is: server, the printer host name is: HP, and the client host name is: client.

First, run the following command to start the CUPS printing service:
/Etc/init. d/cups start

Then, in the CUPS server host server, we need to set two files:
/Etc/cups/cupsd. conf
/Etc/cups/printers. conf

Cupsd. conf controls the settings of the cups service, while printers. conf sets the printer.

Setting these two files is not complex. We do not recommend that you manually modify them here, because you can set them on the web and then generate them automatically.
You only need to enter this URL in the web browser of the Local Machine to enter the CUPS web Settings interface:

Http: // server host name: 631 For example: http: // server: 631

But here, I think we need to introduce the content in these two files, which will be helpful for everyone's understanding.
In addition, I found that if you want to restrict users, it seems that you still need to manually modify the printers. conf file.

Content in the cupsd. conf file:
#======================================

AuthType Basic
AuthClass System
Order Deny, Allow
Deny From All
Allow From 127.0.0.1

# The above section sets the CUPS service management permissions. Generally, you can only modify and control the CUPS service from the local machine.
# The allow address is 127.0.0.1.


Order Deny, Allow
Deny From All
Allow From All

# The above section sets the default function permissions for the CUPS service. In general, there is nothing special.

#
# End of "$ Id: cupsd. conf. in, v 1.16 2004/08/18 17:53:47 mike Exp $ ".
#

# Lines below are automatically generated-DO NOT EDIT
# The following section sets the use of the printer in CUPS. Because the server is only a computer after all, it still needs to be printed through a printer.
# From the Perspective of settings, the permission is basically open to all users. If you want to restrict the IP address area, you need to set it after Allow.

# Note that in the above line, HP is the name of the printer, which must be the same as that set in printers. cups.
Order Deny, Allow
Deny From All
AuthType None
Allow from All


#======================================

Content in the printers. conf file:
#======================================
# HP in the following line is the name of the printer. We recommend that you use the network host name of the printer for ease of configuration.

Info Created by redhat-config-printer 0.6.x
DeviceURI lpd: // HP/PORT1
State Idle
Accepting Yes
JobSheets none
QuotaPeriod 0
PageLimit 0
KLimit 0
AllowUser root
AllowUser PETER
AllowUser SUSAN

#======================================
Here, we will focus on the line in the bold text in the above section.
DeviceURI lpd: // HP/PORT1
This line defines the protocol used by the printer to connect to the CUPS server. Other candidate protocols are as follows:
File:/path/to/filename. prn
Http: // hostname: 631/ipp/
Http: // hostname: 631/ipp/port1
Ipp: // hostname/ipp/
Ipp: // hostname/ipp/port1
Lpd: // hostname/queue
Socket: // hostname
Socket: // hostname: 9100

In the above print protocols, hostname refers to the network host name of the printer, you can also use the IP address of the printer instead, 631 is the CUPS service port number
Among them, port1 is generally the default queue of the HP printer. If it is a multi-queue printer, you can log on to the printer through the ftp protocol, and then see what directories are under the root directory of the printer system, we can determine the queue name.

Pay attention to one problem here, because in actual operations, I found that the printer settings of the redhat-config-printer-gui only support printer settings of the LPD protocol. That is to say, if you use IPP, HTTP, or socket, even if the configuration is successful, the test page can be printed, however, you cannot use the redhat-config-printer-gui to set the printer asynchronously. For convenience, we recommend that you use LPD to set the connection between the CUPS server and the printer.

The AllowUser statement allows or limits the print permission of a specific user. If this statement is not used, all users can print the statement.
This statement must be manually added.
* Note that the AllowUser statement is automatically deleted each time the redhat-config-printer-gui is configured. You need to add a new AllowUser statement.
In addition, you can add the following content to the cupsd. conf file:
After completing the preceding settings, it is difficult to manually configure IP address segments. Therefore, the redhat-config-printer-gui is used for configuration.
The following part is automatically generated in the cupsd. conf file after the redhat-config-printer-gui settings are used. We do not recommend that you manually add it.
However, if you want to use the redhat-printer-config-gui to modify the settings, you must use the LPD protocol in the printers. conf file:
#==================================
Browsing On
BrowseProtocols cups
BrowseOrder Deny, Allow
BrowseAllow from @ LOCAL
BrowseAddress 255.255.255.255
Listen *: 631.
#==================================

In this example, the Listen statement sets network restrictions that allow the use of the CUPS service. "*" Indicates all networks
I can see in some documents that if you want to set the network area, you need to write it in the following format:
Listen 0.0.0.0: 631
But it is actually wrong. If it is written as above, it will lead to an error in starting the CUPS service.
The following error message is displayed: Child exited with status: 98!
Therefore, the correct method is to use the * number instead of all networks.
You can use the share option in the redhat-printer-config-gui to control the settings of IP networks in other regions. This is very convenient and will not be listed here.

After completing the preceding steps, restart the CUPS service.
Run The lpq. cups command to check the printer status. If "HP is ready" is displayed, the CUPS server is successfully set.

Client settings:
The premise is that the firewall of the CUPS server should be enabled. At least 631 port numbers cannot be blocked.
The client settings are very simple. You only need to configure one file:
/Etc/cups/client. conf

Client. conf file content:
#======================================
# ServerName CUPS server address or server name, for example:

ServerName server

#======================================
It is really easy. After setting it, restart the CUPS service.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.