Configure network printer sharing in Linux

Source: Internet
Author: User
Article title: Configure network printer sharing in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Author: Bryan Pfaffenberger, TechRepublic
  
When connecting to the LAN, a focus is on how to share the printer, thus saving a lot of money
. Consider how much it costs to equip every user with a decent printer. Like other network operating systems, Linux provides a good environment for printer sharing in the network. If you use Linux, you do not have to spend a lot of money on commercial applications and hardware that you don't need. If Linux can do the same job at a very small cost or without any cost, why should we buy HP's expensive printer servers? Let's take a look at how to share a printer in a Linux local environment.
  
Prerequisites: local printer
This article assumes that a local printer has been installed in your Linux system and describes how to share your printer on the network. If you have not installed a local printer, you need to install one first and then read this article again. Now Linux has more easy-to-use and friendly printer configuration tools, such as Red Hat printing tools. If you are not using Red Hat, please check your documents and how to install a printer in your system.
  
Introduction to Line Printer Daemon (lpd)
  
Although some Linux configurations provide optional Printer interfaces, Line Printer Daemon (lpd) is common ). When an application needs to print services, lpd is triggered. It creates a print output file in the temporary storage area of/var/spool/lpd, finds the printer, and splits and packs the print output according to the printer speed. If lpd receives another print request before completing the first job, it creates a queue waiting for the print file. Since different printers have different features, how does lpd know how to print a file? The lpd configuration file/etc/printcap will tell you the answer. There is one or more sub-sections in this file. like a poem, it is a configuration command block. Each section defines a printer that provides information such as how a Printer connects to a computer and which filter file will be used. For each printer, it has a unique filter file. It defines the features and performance of this printer.
  
Remember that lpd is a network service, even if you apply Linux to a single machine or workstation with only one user. When an application requires lpd services, it sends a request through TCP/IP. Therefore, if a local application can send service requests through the local lpd, any application in the network can do the same. If you configure the server and client correctly, network printing will become completely transparent to users.
  
Before using Linux, if you have been working in a Windows network, you may think that to share the printer in the network, you can install the Network File System (NFS) on the server or client) services are necessary. In Windows, network printing and file sharing are supported by the same huge and complex protocol, which is called the service information Block (SMB ). But Linux is not like this. due to UNIX inheritance, the tool set of Linux is smaller, functions are more concentrated, and there are fewer bugs. NFS processes file sharing independently of printing and sharing. Similarly, NFS is not required for lpd to process print shares.
  
Before we start, I should clarify some terms
. The server in Linux refers to the host connected to the printer, and the client refers to the host remotely using the printer. For example, in a network with four hosts (luke, leia, yoda, and han), the printer is installed on luke. Therefore, luke is the server, and other hosts will remotely use the printer, which is the client. To make a local printer a network printer, perform the following steps:
  
On the server side, create an account for each customer who remotely uses the printer. Create a configuration file named/etc/hosts. lpd. This file includes the host name or IP address of the printer.
  
In each client, add a section in/etc/printcap to describe the characteristics and location of the printer. You can use the built-in configuration tool of Linux to configure the printer, or manually configure the/etc/printcap file for each client system.
  
Step 1: First prepare the network printing server.
Please note that the server must be sure that the printer is properly connected and can work properly. Now, make sure that all users who need to print services on the host have an account. If you plan to use NFS, make sure that the account content is unique: user name, user ID (UID), Master member group, and master ID Group (GID ).
  
On the host connected to the printer, open a terminal window and use the superuser to enter. Create a new file in the text editor. if you want to provide network printing services for leia, yoda, and han on luke, type
  
Leia
Yoda
Han
  
To use these user names, all hosts on the network must list each user name, corresponding IP address, and domain name in the/etc/hosts file, as shown below:
  
192.168.1.10 luke.mydomain.org luke
192.168.1.11 leia.mydomain.org leia
192.168.1.12 yoda.mydomain.org yoda
192.158.1.13 han.mydomain.org han
  
If you do not use this method to create your/etc/hosts file, you can also replace the user name with the IP address of each client, as shown below:
  
192.168.1.11
192.168.1.12
192.168.1.13
  
After that, you can save the file and exit.
  
Author's comment
If you have read some files about the Internet earlier, you may think that the correct configuration file name is/etc/hosts. equiv, but do not use this name to create and use files! It has a major security vulnerability. Hosts listed in hosts. equiv can access the server without any restrictions. it is obviously not a good thing to allow such access, even in a small network where everyone trusts each other and no one does anything bad. If an accident occurs or someone does something bad, you should avoid harming other systems on the network. In a large network, especially in a network connected to the Internet, using hosts. equiv is troublesome. On the contrary, hosts. lpd can be used to share the printer in the network without the risk of hosts. equiv.
  
Step 2: configure the client
In order for your client to remotely use the printer, you need to know how to use the print configuration tool in your Linux to create a client. If you are using a Red Hat or Red Hat-based system, you can use the built-in printing tool. Other systems provide similar tools. Although these instructions are for specific printing tools, you should be able to adapt the following steps to your printer configuration tools:
  
Log on with system permissions and enable the printer configuration tool. In Red Hat or Red Hat-based systems, run the configuration tool as a super user, type/usr/sbin/printtool, and press enter. You will see the printing system manager of Red Hat Linux.
  
Click ADD to create a new printer model. a printer login dialog box is added.
  
Select delete Unix (lpd) queue and click OK. You will see the edit remote Unix (lpd) queue logon dialog box.
  
Enter one or more names for the printer, separated by a vertical line. if the system prompts a name, you should use it. The address provided by the system is accepted at the address filled in. For remote printers, each client has its own local print address. Enter the IP address of the host to which the printer is connected.
  
Enter the name queue of the remote printer in the remote queue field. If only one printer is defined in the remote system, type lp. If there is more than one printer in the/etc/printcap file of the remote system, open the file and determine the name (such as lp0, lp1, or lp2) in the printer queue ).
  
Open the Input Filter file and select the computer type from the list. If your Printer is not in the list and belongs to another type, select PostScript Printer. Click OK to exit the Input Filter list.
  
Click OK to confirm the settings of the network printer. these will be added and saved in/etc/printcap. If you are using another printer configuration tool, make sure that your configuration settings are saved. Click Tests on the menu bar and select Print PostScript Test Page to Print the Test Page for the printer.
  
If the test fails, you need to find the cause. First, the printer on the server is working properly. Then, check your/etc/hosts. lpd file again (see the first step above ). Are you sure you want to enter the computer name or IP address? Then, check the client configuration. Check your input carefully. Now, try to use the printer from the user account of the problematic host. If the remote printer works normally in the print test tool, the user account on the server must be faulty. To achieve remote printing, the server must have the same account as the client where the user is located. If there is any difference between two users, such as a conflict between the user ID or the primary member group, change it. (In the Red Hat system, you can use LinuxConf to change the user account information .)
  
Repeat the preceding steps on all clients in the network. If a remote printer is used on the client, the problem is almost certainly caused by the user account on the server, the/etc/hosts. lpd file on the server, or a simple input error.
  
About/etc/printcap
  
If you want to know more about how lpd supports remote printing, see the section created by the printer configuration tool in/etc/printcap.
. However, do not make any changes unless you are sure what you are doing. In particular, do not make any changes if this section is written by the configuration tool. Some tools, such as Red Hat printing tools, have their own specific syntax rules. any changes you make can stop your printer. If you must change your printer settings, run the tool again. This example shows that a client successfully uses a remote printer:
  
Lp | grumpy | deskjet: sd =/var/spool/lpd/lp: mx = #0: sh: rm = 192.168.100.34: rp = lp :: if =/var/spool/lpd/lp/filter:
  
It is not suitable for long discussions on/etc/printcap, but I should point out some notes:
  
A section must be expressed in a row. Although this may be hard to understand, you can insert a backslash to separate a row. If the printer does not work properly, make sure that the section of each line ends with a backslash (except the last line, of course ).
  
The colon divides the section into several parts.
  
In the first line of the list, the printer and the corresponding name are displayed. Use a vertical line to open the printer.
  
Some variables are Boolean and can be set to yes/no or on/off. If they exist in files, they will automatically take effect.
  
For other variables, you must specify a value and assign an equal sign to the value, for example, sd =/var/spool/lpd/lp. There are also some numeric variables that use the numeric operator # to assign values, for example, mx #0.

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.