Translated Over: disylee <disylee@hotmail.com>

This commit is contained in:
disylee 2014-10-13 01:14:50 +08:00
parent 9889db3684
commit 9d58850cb3
2 changed files with 245 additions and 201 deletions

View File

@ -1,201 +0,0 @@
诗诗来翻译disylee
How to configure a network printer and scanner on Ubuntu desktop
================================================================================
In a [previous article][1](注这篇文章在2014年8月12号的原文里做过不知道翻译了没有如果翻译发布了发布此文章的时候可改成翻译后的链接), we discussed how to install several kinds of printers (and also a network scanner) in a Linux server. Today we will deal with the other end of the line: how to access the network printer/scanner devices from a desktop client.
### Network Environment ###
For this setup, our server's (Debian Wheezy 7.2) IP address is 192.168.0.10, and our client's (Ubuntu 12.04) IP address is 192.168.0.105. Note that both boxes are on the same network (192.168.0.0/24). If we want to allow printing from other networks, we need to modify the following section in the cupsd.conf file on the sever:
<Location />
Order allow,deny
Allow localhost
Allow from XXX.YYY.ZZZ.*
</Location>
(in the above example, we grant access to the printer from localhost and from any system whose IPv4 address starts with XXX.YYY.ZZZ)
To verify which printers are available on our server, we can either use lpstat command on the server, or browse to the https://192.168.0.10:631/printers page.
root@debian:~# lpstat -a
----------
EPSON_Stylus_CX3900 accepting requests since Mon 18 Aug 2014 10:49:33 AM WARST
PDF accepting requests since Mon 06 May 2013 04:46:11 PM WARST
SamsungML1640Series accepting requests since Wed 13 Aug 2014 10:13:47 PM WARST
![](https://farm4.staticflickr.com/3903/14777969919_7b7b25a4a4_z.jpg)
### Installing Network Printers in Ubuntu Desktop ###
In our Ubuntu 12.04 client, we will open the "Printing" menu (Dash -> Printing). Note that in other distributions the name may differ a little (such as "Printers" or "Print & Fax", for example):
![](https://farm4.staticflickr.com/3837/14964314992_d8bd0c0d04_o.png)
No printers have been added to our Ubuntu client yet:
![](https://farm4.staticflickr.com/3887/14941655516_80430529b5_o.png)
Here are the steps to install a network printer on Ubuntu desktop client.
**1)** The "Add" button will fire up the "New Printer" menu. We will choose "Network printer" -> "Find Network Printer" and enter the IP address of our server, then click "Find":
![](https://farm6.staticflickr.com/5581/14777977730_74c29a99b2_z.jpg)
**2)** At the bottom we will see the names of the available printers. Let's choose the Samsung printer and press "Forward":
![](https://farm6.staticflickr.com/5585/14941655566_c1539a3ea0.jpg)
**3)** We will be asked to fill in some information about our printer. When we're done, we'll click on "Apply":
![](https://farm4.staticflickr.com/3908/14941655526_0982628fc9_z.jpg)
**4)** We will then be asked whether we want to print a test page. Lets click on "Print test page":
![](https://farm4.staticflickr.com/3853/14964651435_cc83bb35aa.jpg)
The print job was created with local id 2:
![](https://farm6.staticflickr.com/5562/14777977760_b01c5338f2.jpg)
5) Using our server's CUPS web interface, we can observe that the print job has been submitted successfully (Printers -> SamsungML1640Series -> Show completed jobs):
![](https://farm4.staticflickr.com/3887/14778110127_359009cbbc_z.jpg)
We can also display this same information by running the following command on the printer server:
root@debian:~# cat /var/log/cups/page_log | grep -i samsung
----------
SamsungML1640Series root 27 [13/Aug/2014:22:15:34 -0300] 1 1 - localhost Test Page - -
SamsungML1640Series gacanepa 28 [18/Aug/2014:11:28:50 -0300] 1 1 - 192.168.0.105 Test Page - -
SamsungML1640Series gacanepa 29 [18/Aug/2014:11:45:57 -0300] 1 1 - 192.168.0.105 Test Page - -
The page_log log file shows every page that has been printed, along with the user who sent the print job, the date & time, and the client's IPv4 address.
To install the Epson inkjet and PDF printers, we need to repeat steps 1 through 5, and choose the right print queue each time. For example, in the image below we are selecting the PDF printer:
![](https://farm4.staticflickr.com/3926/14778046648_c094c8422c_o.png)
However, please note that according to the [CUPS-PDF documentation][2], by default:
> PDF files will be placed in subdirectories named after the owner of the print job. In case the owner cannot be identified (i.e. does not exist on the server) the output is placed in the directory for anonymous operation (if not disabled in cups-pdf.conf - defaults to /var/spool/cups-pdf/ANONYMOUS/).
These default directories can be modified by changing the value of the **Out** and **AnonDirName** variables in the /etc/cups/cups-pdf.conf file. Here, ${HOME} is expanded to the user's home directory:
Out ${HOME}/PDF
AnonDirName /var/spool/cups-pdf/ANONYMOUS
### Network Printing Examples ###
#### Example #1 ####
Printing from Ubuntu 12.04, logged on locally as gacanepa (an account with the same name exists on the printer server).
![](https://farm4.staticflickr.com/3845/14778046698_57b6e552f3_z.jpg)
After printing to the PDF printer, let's check the contents of the /home/gacanepa/PDF directory on the printer server:
root@debian:~# ls -l /home/gacanepa/PDF
----------
total 368
-rw------- 1 gacanepa gacanepa 279176 Aug 18 13:49 Test_Page.pdf
-rw------- 1 gacanepa gacanepa 7994 Aug 18 13:50 Untitled1.pdf
-rw------- 1 gacanepa gacanepa 74911 Aug 18 14:36 Welcome_to_Conference_-_Thomas_S__Monson.pdf
The PDF files are created with permissions set to 600 (-rw-------), which means that only the owner (gacanepa in this case) can have access to them. We can change this behavior by editing the value of the **UserUMask** variable in the /etc/cups/cups-pdf.conf file. For example, a umask of 0033 will cause the PDF printer to create files with all permissions for the owner, but read-only privileges to all others.
root@debian:~# grep -i UserUMask /etc/cups/cups-pdf.conf
----------
### Key: UserUMask
UserUMask 0033
For those unfamiliar with umask (aka user file-creation mode mask), it acts as a set of permissions that can be used to control the default file permissions that are set for new files when they are created. Given a certain umask, the final file permissions are calculated by performing a bitwise boolean AND operation between the file base permissions (0666) and the unary bitwise complement of the umask. Thus, for a umask set to 0033, the default permissions for new files will be NOT (0033) AND 0666 = 644 (read / write / execute privileges for the owner, read-only for all others.
### Example #2 ###
Printing from Ubuntu 12.04, logged on locally as jdoe (an account with the same name doesn't exist on the server).
![](https://farm4.staticflickr.com/3907/14964315142_a71d8a8aef_z.jpg)
root@debian:~# ls -l /var/spool/cups-pdf/ANONYMOUS
----------
total 5428
-rw-rw-rw- 1 nobody nogroup 5543070 Aug 18 15:57 Linux_-_Wikipedia__the_free_encyclopedia.pdf
The PDF files are created with permissions set to 666 (-rw-rw-rw-), which means that everyone has access to them. We can change this behavior by editing the value of the **AnonUMask** variable in the /etc/cups/cups-pdf.conf file.
At this point, you may be wondering about this: Why bother to install a network PDF printer when most (if not all) current Linux desktop distributions come with a built-in "Print to file" utility that allows users to create PDF files on-the-fly?
There are a couple of benefits of using a network PDF printer:
- A network printer (of whatever kind) lets you print directly from the command line without having to open the file first.
- In a network with other operating system installed on the clients, a PDF network printer spares the system administrator from having to install a PDF creator utility on each individual machine (and also the danger of allowing end-users to install such tools).
- The network PDF printer allows to print directly to a network share with configurable permissions, as we have seen.
### Installing a Network Scanner in Ubuntu Desktop ###
Here are the steps to installing and accessing a network scanner from Ubuntu desktop client. It is assumed that the network scanner server is already up and running as described [here][3].
**1)** Let us first check whether there is a scanner available on our Ubuntu client host. Without any prior setup, you will see the message saying that "No scanners were identified."
$ scanimage -L
![](https://farm4.staticflickr.com/3906/14777977850_1ec7994324_z.jpg)
**2)** Now we need to enable saned daemon which comes pre-installed on Ubuntu desktop. To enable it, we need to edit the /etc/default/saned file, and set the RUN variable to yes:
$ sudo vim /etc/default/saned
----------
# Set to yes to start saned
RUN=yes
**3)** Let's edit the /etc/sane.d/net.conf file, and add the IP address of the server where the scanner is installed:
![](https://farm6.staticflickr.com/5581/14777977880_c865b0df95_z.jpg)
**4)** Restart saned:
$ sudo service saned restart
**5)** Let's see if the scanner is available now:
![](https://farm4.staticflickr.com/3839/14964651605_241482f856_z.jpg)
Now we can open "Simple Scan" (or other scanning utility) and start scanning documents. We can rotate, crop, and save the resulting image:
![](https://farm6.staticflickr.com/5589/14777970169_73dd0e98e3_z.jpg)
### Summary ###
Having one or more network printers and scanner is a nice convenience in any office or home network, and offers several advantages at the same time. To name a few:
- Multiple users (connecting from different platforms / places) are able to send print jobs to the printer's queue.
- Cost and maintenance savings can be achieved due to hardware sharing.
I hope this article helps you make use of those advantages.
--------------------------------------------------------------------------------
via: http://xmodulo.com/2014/08/configure-network-printer-scanner-ubuntu-desktop.html
作者:[Gabriel Cánepa][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/gabriel
[1]:http://xmodulo.com/2014/08/usb-network-printer-and-scanner-server-debian.html
[2]:http://www.cups-pdf.de/documentation.shtml
[3]:http://xmodulo.com/2014/08/usb-network-printer-and-scanner-server-debian.html#scanner

View File

@ -0,0 +1,245 @@
如何在ubuntu桌面配置一个网络打印机和扫描仪
================================================================================
在[之前的文章中](注这篇文章在2014年8月12号的原文里做过不知道翻译了没有如果翻译发布了发布此文章的时候可改成翻译后的链接), 我们讨论过如何在Linux服务器安装各种各样的打印机当然也包括网络扫描仪。今天我们将来处理另一端如何通过桌面客户端来访问网络打印机/扫描仪。
### 网络环境 ###
在这个安装教程中我们的服务器Debian Wheezy 7.2版本的IP地址是192.168.0.10,我们的客户端(Ubuntu 12.04版本)的IP地址是192.168.0.105.注意这两台机器是在同一个网段192.168.0.0/24).如果我们想允许打印机访问其它网段我们需要在服务器上修改cupsd.conf文件的以下部分
<Location />
Order allow,deny
Allow localhost
Allow from XXX.YYY.ZZZ.*
</Location>
在上述例子中我们授予打印机从本地或者任何系统能够访问打印机这些系统的IPv4地址以XXX.YYY.ZZZ开始。
为了验证哪些打印机可以在我们的服务器上适用我们也可以在服务器上使用lpstat命令或者浏览网页https://192.168.0.10:631/printers page.
root@debian:~# lpstat -a
----------
EPSON_Stylus_CX3900 accepting requests since Mon 18 Aug 2014 10:49:33 AM WARST
PDF accepting requests since Mon 06 May 2013 04:46:11 PM WARST
SamsungML1640Series accepting requests since Wed 13 Aug 2014 10:13:47 PM WARST
![](https://farm4.staticflickr.com/3903/14777969919_7b7b25a4a4_z.jpg)
### 在Ubuntu桌面安装网络打印机 ###
在我们的Ubuntu 12.04的客户端,我们将打开"Printing"菜单(Dash -> Printing).你会注意到在其它发行版中,这个名字也许会有一点差别(例如会叫做"Printers" 或者 "Print & Fax":
![](https://farm4.staticflickr.com/3837/14964314992_d8bd0c0d04_o.png)
还没有打印机添加到我们的客户端:
![](https://farm4.staticflickr.com/3887/14941655516_80430529b5_o.png)
下面是在Ubuntu桌面客户端安装一台网络打印机的一些步骤。
**1)** “Add”按钮将弹出New Printer" 菜单。我们将选择"Network printer" -> "Find Network Printer"并输入我们服务器的IP地址接着点击"Find":
![](https://farm6.staticflickr.com/5581/14777977730_74c29a99b2_z.jpg)
**2)** 在最下面我们将会看到可使用的打印机的名称。我们来选择这台三星打印机并按"Forward":
![](https://farm6.staticflickr.com/5585/14941655566_c1539a3ea0.jpg)
**3)** 我们将会被要求填写一些关于我们打印机的信息。当我们输入完成时,将点击 "Apply"按钮。
![](https://farm4.staticflickr.com/3908/14941655526_0982628fc9_z.jpg)
**4)** 我们接下来将被询问是否打印一张测试页。让我们点击"Print test page"吧:
![](https://farm4.staticflickr.com/3853/14964651435_cc83bb35aa.jpg)
这个打印任务将被创建为本地id 2
![](https://farm6.staticflickr.com/5562/14777977760_b01c5338f2.jpg)
5)适用我们服务器上的CUPS网络借口我们可以观察到打印任务已经提交成功了打印机 -> SamsungML1640系列 -> 显示完成任务):
![](https://farm4.staticflickr.com/3887/14778110127_359009cbbc_z.jpg)
我们也可以通过在打印机服务器上运行以下命令显示同样信息:
root@debian:~# cat /var/log/cups/page_log | grep -i samsung
----------
SamsungML1640Series root 27 [13/Aug/2014:22:15:34 -0300] 1 1 - localhost Test Page - -
SamsungML1640Series gacanepa 28 [18/Aug/2014:11:28:50 -0300] 1 1 - 192.168.0.105 Test Page - -
SamsungML1640Series gacanepa 29 [18/Aug/2014:11:45:57 -0300] 1 1 - 192.168.0.105 Test Page - -
这个page_log日志显示每一页被打印过的信息只包括哪些用户发送这些打印任务打印日期&时间以及客户端的IPv4地址。
要安装Epson喷墨和PDF打印机我们只需重复第1-5的步骤即可并每一次选择左边的打印队列。例如在下图中选择PDF打印机
![](https://farm4.staticflickr.com/3926/14778046648_c094c8422c_o.png)
然而,请注意到根据[CUPS-PDF 文档中][2],根据默认:
>PDF文件将会被放置在打印作业的所有者命名的子目录内。在这个案例中打印作业的所有者不能被识别i.e.不会存在服务器中)输出的内容被放置在匿名操作的文件中。
这些默认的文件夹可以通过改变在/etc/cups/cups-pdf目录中的**Out**值和**AnonDirName**变量来修改。这里,${HOME}被扩展到用户的家目录中:
Out ${HOME}/PDF
AnonDirName /var/spool/cups-pdf/ANONYMOUS
### 网络打印实例 ###
#### 实例 #1 ####
从Ubuntu12.04中打印通常在本地用gacanepa具有相同名字存在打印机服务器上
![](https://farm4.staticflickr.com/3845/14778046698_57b6e552f3_z.jpg)
打印到PDF打印机之后让我们来检查打印机服务器上的/home/gacanepa/PDF目录下的内容
root@debian:~# ls -l /home/gacanepa/PDF
----------
total 368
-rw------- 1 gacanepa gacanepa 279176 Aug 18 13:49 Test_Page.pdf
-rw------- 1 gacanepa gacanepa 7994 Aug 18 13:50 Untitled1.pdf
-rw------- 1 gacanepa gacanepa 74911 Aug 18 14:36 Welcome_to_Conference_-_Thomas_S__Monson.pdf
这个PDF文件被创建时的权限已经设置为600(-rw-------),这意味着只有打印任务的所有者(在这个例子中是gacanepa )可以访问它们。我们可以通过修改the /etc/cups/cups-pdf.conf文件**UserUMask**变量的值来改变这种行为。例如0033的umask值将可以使PDF打印者以及其它所有者拥有创建文件的权限但是只读权限也会赋予给其它所有者。
root@debian:~# grep -i UserUMask /etc/cups/cups-pdf.conf
----------
### Key: UserUMask
UserUMask 0033
对于那些不熟悉umask有名用户文件创建模式掩码它作为一组可以用于控制那些为新文件创建时修改默认权限。umask是掩码的意思教你如何判断一个用户对文件的操作权限共有 读 写 执行 三种操作权限).通过文件本身提供的权限由0666表示、用户想执行的操作读、写、还是执行这两者的“与”计算确定用户有没有权限操作这个文件。因此如果设置一个umask值为0033那么新文件默认的权限将不是0033AND 0666 = 644的值文件拥有者具有读/写/执行的权限,其他人拥有只读权限)。
### 实例 #2 ###
在Ubuntu12.04执行打印本地登录用户为jdoe同样的帐号名称但是服务器上是不存在的
![](https://farm4.staticflickr.com/3907/14964315142_a71d8a8aef_z.jpg)
root@debian:~# ls -l /var/spool/cups-pdf/ANONYMOUS
----------
total 5428
-rw-rw-rw- 1 nobody nogroup 5543070 Aug 18 15:57 Linux_-_Wikipedia__the_free_encyclopedia.pdf
这个PDF被创建时赋予的权限是666(-rw-rw-rw-),这意味着每个人都可以访问它们。我们可以通过编辑在/etc/cups/cups-pdf.conf文件中的**AnonUMask**值来改变这种行为。
在这一点上你也许会疑惑为什么同样安装一台网络打印机大多数当然不是全部当前的Linux桌面发行版都会内置一个"打印到文件"的功能来允许用户动态创建PDF文件
使用一台网络PDF打印机有以下好处
- 一个网络打印机(任何类型的)允许你直接从命令行直接打印,无需首先打开文件。
- 在其它操作系统上安装一个网络客户端一个PDF网络打印机备件于是系统管理员不必再单独需要安装PDF创建者实用程序也避免了最终用户安装这些工具存在的风险
- 网络PDF打印机允许通过配置权限直接打印一个网络共享如我们所见的例子。
### 在Ubuntu桌面安装一个网络扫描仪 ###
这里是通过Ubuntu桌面客户端安装和访问一台网络扫描仪的一些步骤。假设网络扫描仪服务器已经启动并运行所述[here][3].
**1)**让我们第一步来检查在我们的Ubuntu客户端主机上是否存在一台可用的扫描仪。没有先前的安装你将会看到信息提示"没有识别到扫描仪."
$ scanimage -L
![](https://farm4.staticflickr.com/3906/14777977850_1ec7994324_z.jpg)
**2)** 现在我们需要启用saned进程用来预装Ubuntu桌面。要启用它我们需要编辑/etc/default/saned文件并设置RUN变量为yes
$ sudo vim /etc/default/saned
----------
# Set to yes to start saned
RUN=yes
**3)** 让我们编辑/etc/sane.d/net.conf文件并在扫描仪安装后添加服务器IP地址
![](https://farm6.staticflickr.com/5581/14777977880_c865b0df95_z.jpg)
**4)** 重启saned进程
$ sudo service saned restart
**5)** 现在让我们来看看扫描仪是否可用:
![](https://farm4.staticflickr.com/3839/14964651605_241482f856_z.jpg)
现在我们可以打开"Simple Scan"(或者其它扫描工具)并开始扫描文件。我们可以旋转,修剪,和保存生成的图片:
![](https://farm6.staticflickr.com/5589/14777970169_73dd0e98e3_z.jpg)
### 总结 ###
拥有一或多台网络打印机或扫描仪在任何办公和家庭网络中都是非常方便适用的,并同时提供了许多好处。例举如下:
- 多用户(从不同的平台/地方)都能够向打印机发送打印作业的队列。
- 由于硬件共享达到了节约成本和维护的作用。
我希望这篇文章可以帮助你更充分地利用这些有点。
--------------------------------------------------------------------------------
via: http://xmodulo.com/2014/08/configure-network-printer-scanner-ubuntu-desktop.html
作者:[Gabriel Cánepa][a]
译者:[disylee](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/gabriel
[1]:http://xmodulo.com/2014/08/usb-network-printer-and-scanner-server-debian.html
[2]:http://www.cups-pdf.de/documentation.shtml
[3]:http://xmodulo.com/2014/08/usb-network-printer-and-scanner-server-debian.html#scanner