印表機的共享

Linux 對 Linux

Once you have CUPS setup on your Linux print server, sharing the printer with another Linux box is relatively easy. There are several ways to configure such a scenario, here we will describe the manual setup. On the server computer (the one managing and connecting to the printer) simply open up the /etc/cups/cupsd.conf file and allow access to the server by modifying the location lines. For instance:

<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 10.0.0.*
</Location>

You will also need to make sure the server is listening on the IP address your client will be addressing. Add the following line after "Listen localhost:631":

Listen 10.0.0.1:631

using your server's IP address instead of 10.0.0.1.

Add the IP address of the client computer by doing Allow From client_ip_address. After you make your modifications, you will want to restart CUPS by doing:

# /etc/rc.d/cupsd restart

On the client side, open up /etc/cups/client.conf and edit the ServerName option to match the ip address or the name of your server. For instance I named my server beast and have entry in my hosts file to point to it. So in my client.conf file, I just edited this line:

Linux to Windows

If you are connected to a Windows print server (or any other Samba capable print server), you can skip the section about kernel modules and such. All you have to do is start the CUPS daemon and complete the web interface as specified in section 3.3 and 3.4. Before this, you need to activate the Samba CUPS backend. You can do this by entering the following command:

# ln -s `which smbspool` /usr/lib/cups/backend/smb

Note that the symbol before is ` (underneath the ~ on a standard US keyboard) and not '. After this, you will have to restart CUPS using the command specified in the previous section. Next, simply login into the CUPS web interface and choose to add a new printer. For device, there should be an option that says something to the effect Windows Printer Via Samba near the button of the device list. For the device location enter:

smb://username:password@hostname/printer_name

Or without a password:

smb://username@hostname/printer_name

Make sure that the user actually has access to the printer on Windows computer. Select the appropriate drivers and that's about it. If the computer is located on a domain, make sure the username includes the domain:

smb://username:password@domain/hostname/printer_name

Note: if your network contains many printers use "lpoptions -d your_desired_default_printer_name" to set your preferred printer

Note: I, thepizzaking, was having 'NT_STATUS_ACCESS_DENIED' errors and to fix them I needed to use a slightly different syntax:

smb://workgroup/username:password@hostname/printer_name

Windows to Linux

Sometimes, you might want to allow a Windows computer to connect to your computer. There are a few ways to do this, and the one I am most familiar with is using Samba. In order to do this, you will have to edit your /etc/samba/smb.conf file to allow access to your printers. Your smb.conf can look something like this:

Please note that in my configuration I made it so that users must have a valid account to access the printer. To have a public printer, set guest ok to yes, and remove the valid users line. To add accounts, you must setup a regular Linux account and then setup a Samba password on the server. For instance:

# useradd neocephas
# smbpasswd -a neocephas

After setting up any user accounts that you need, you will also need to set up the samba spool folder:

# mkdir /var/spool/samba
# chmod 777 /var/spool/samba

The next items that need changing are /etc/cups/mime.convs and /etc/cups/mime.types:

mime.convs:

# The following line is found at near the end of the file. Uncomment it.
application/octet-stream application/vnd.cups-raw 0 -

mime.types:

# Again near the end of the file.
application/octet-stream

The changes to mime.convs and mime.types are needed to make CUPS print Microsoft Office document files. Many people seem to need that.

After this restart your Samba daemon:

# /etc/rc.d/samba restart

Obvious, there are a lot of tweaks and customization that can be done with setting up a Samba print server, so I advise you to look at the Samba and CUPS documentation for more help. The smb.conf.example file also has some good samples to that you might want to look at.

Windows 2000 and Windows XP to Linux

For the most modern flavors of Windows an alternative way of connecting to your Linux printer server is to use the CUPS protocol directly. The Windows client will need to be using Windows 2000 or Windows XP. Make sure you allows the clients to access the print server by editing the location settings as specified in section 4.1.

On the Windows computer, go to the printer control panel and choose to Add a New Printer. Next, choose to give an url. For the url type in the location of your printer:

where host_ip_address is the Linux server's IP address and printer_name is the name of the printer you are connecting to. After this, install the printer drivers for the Windows computer. If you setup the CUPS server to use its own printer drivers, then you can just select a generic postscript printer for the Windows client. You can then test your print setup by printing a test page.

PDF Virtual Printer

A nice little package that I submitted to the incoming folder (ftp://ftp.archlinux.org/incoming) is CUPS-PDF. This package allows one to setup a virtual printer that will generate a PDF from anything sent to it. For example, I wrote this document in AbiWord and then printed it to the Virtual Printer which generated a PDF in my /var/spool/cups-pdf/neocephas folder. Obviously, this package is not necessary, but it can be quite useful. After downloading the package from the FTP server and installing it, you can set it up as you would for any other printer in the web interface. Select Virtual PDF Printer as the device and choose Postscript -> Postscript Color Printer for the drivers.

Specialized Cases

This section is dedicated to specific problems and their solutions. If you managed to get some unusual printer working, please put the solution here.

Printing does not work/aborts with the HP Deskjet 700 Series Printers.

The solution is to install pnm2ppa printer filter for the HP Deskjet 700 series. Without this the print jobs will be aborted by the system. A PKGBUILD for pnm2ppaAUR can be found in the AUR.

Getting HP LaserJet 1010 to work

I had to compile ghostscript myself because ESP gs in rep was 7.07 and had not fixed some bugs like ESP 8.15.1 had. I never downloaded 'foomatic' in rep. I think that is an old package.

$ pacman -Qs cups a2ps psutils foo ghost
local/cups 1.1.23-3
The CUPS Printing System
local/a2ps 4.13b-3
a2ps is an Any to PostScript filter
local/psutils p17-3
A set of postscript utilities.
local/foomatic-db 3.0.2-1
Foomatic is a system for using free software printer drivers with common
spoolers on Unix
local/foomatic-db-engine 3.0.2-1
Foomatic is a system for using free software printer drivers with common
spoolers on Unix
local/foomatic-db-ppd 3.0.2-1
Foomatic is a system for using free software printer drivers with common
spoolers on Unix
local/foomatic-filters 3.0.2-1
Foomatic is a system for using free software printer drivers with common
spoolers on Unix
local/espgs 8.15.1-1
ESP Ghostscript

I also had to set LogLevel in /etc/cups/cupsd.conf to debug2 before i saw that I missed some "Nimbus" fonts. Then I had to rename & put them where the log told me to. Some fancy google searching had to be applied, example: http://www.google.com/search?q=n019003l+filetype%3Apfb since the fonts turned out to be proprietary (i'm sure windows comes with these default). Nevertheless after downloading them(about 7 fonts) and putting them in the correct folder printing started working.

I'm sure it could have worked with ESP gs 7.07 too(in rep) if i was smart enough to turn on DebugLevel2 sooner :/ UPDATE: yeah it did... maybe this info is useful for someone else though.. sorry for the inconvenience.

Getting HP LaserJet 1020 to work

After a lot of tries with hplib and gutenprint I finally found the solution to get my printer HP Laserjet 1020 printing.

First of all you only need to install cups and ghostscript. Then follow the link on http://www.linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_1020 to the http://foo2zjs.rkkda.com/ printer driver page and follow the install instructions. Log in as root. After you downloaded the package and extracted the archive, change into the foo2zjs directory. Now you can follow the original installation instructions with a minor modification to change the userid for printing:

$ make
$ ./getweb 1020

Open the Makefile

$ nano Makefile

and search for the line

# LPuid=-olp

and modify it to

# LPuid=-oroot

then continue with the script

$ make install
$ make install-hotplug
$ make cups

Or you can use the package foo2zjs from AUR and modify the PKGBUILD: change the line

./getweb all

to

./getweb 1020

(or if you're setting another printer change this line to what you need).

As a last step add and configure the printer in the CUPS manager. The printer should be recognized automatically. It works fine for root and all users. When booting the operating system, the printer is initialized and indicates its working.

Printer connected to an Airport Express Station

The first thing to do is to scan the airport express station. It
seems that there are different addresses depending on the model.

It should work. I had a few problems. There were resolved by removing foomatic and installing foomatic-db, foomatic-db-engine, foomatic-db-ppd instead.

Performing Utility Functions on Epson Printers

Escputil

Here we explain how to perform some of the utility functions such as nozzle cleaning and nozzle checks on Epson printers. We will use the escputil utility, which is part of the gutenprint package.

There is a man page ("man escputil") that provides pretty good information, but it does not include necessary information on how to identify your printer. There are two parameters that can be used. One is --printer; what it expects is the name you used to identify your printer when you configured it. The other is --raw-device. What this option expects is is something beginning with "/dev". If your printer is a serial printer, and the only serial printer, it is "/dev/lp0". If it is an usb printer, it is "/dev/usb/lp0". If you have more than one printer, they will have names ending in "lp1", "lp2", etc.

To clean the printer heads:

escputil -u --clean-head

To prints the nozzle-check pattern, allowing you to verify that the previous head cleaning worked. (Or to determine that you need to clean the heads)

escputil -u --nozzle-check

If you want to perform an operation that requires 2-way communication with a printer, you must use the "--raw-device" specification, and your user must root or be a member of the group "lp".

The following is an example of getting the printer's internal identification:

sudo escputil --raw-device=/dev/usb/lp0 --identify

To prints out the ink levels of the printer:

sudo escputil --raw-device=/dev/usb/lp0 --ink-level

Mtink

This is a printer status monitor which enables to get the remaining ink quantity, to print test patterns, to reset printer and to clean nozzle. It use an intuitive graphical user interface. Package can be downloaded from AUR.

Another Source for Printer Drivers

On http://www.turboprint.de/english.html is a really good printer driver for many printers not yet supported by Linux (especially Canon i*). The only problem is that high-quality-prints are either marked with a turboprint-logo or you have to pay for it... It's not Open-Source.