CUPS

From ArchWiki
Revision as of 16:38, 23 July 2005 by Paranoos (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

1. Introduction

1.1 What is CUPS?

Straight from the CUPS website: \"The Common UNIX Printing System (\"CUPS\") is a cross-platform printing solution for all UNIX environments. It is based on the \"Internet Printing Protocol\" and provides complete printing services to most Postscript and raster printers. CUPS is provided under the GNU GPL...\" Although there are other printing packages such as LPRNG, CUPS is quite popular and relatively easily to use. It is the default printing system on Arch Linux as well as many other Linux distributions.

1.2 Overview of Document

The rest of this document will present a step-by-step process of setting up and configuring CUPS for simple use. I will, as an example, how I managed to setup my printers in order to show how the process can be accomplished. Some users may require more work to get their printers to work, and they are advised read other sources of documentation referenced in the appendix or to ask for assistance in the Arch Linux User Forum. Hopefully, the process presented here will be easy to follow and helpful to most users. Since I am a not a CUPS guru by any means, any corrections or suggestions are greatly appreciated.

As a note, I recommend briefly scanning the whole section that you plan on reading before actually following the steps as there might be some time-saving suggestions towards the end of the section.

       A PDF version of this document can be found at:
       http://www.nd.edu/~~pbui/doc/archlinux-cups-howto.pdf

1.3 Credit

Many thanks go out to all the hard working people developing open source software and who make software packages such as CUPS available. Likewise, I would like to thank the people at various user forums who continue to help newbies such as myself with mundane problems such as configuring a printer. Special recognition goes out to my former daily haunt, Gentoo Linux, and my current focus, Arch Linux. Both have taught me a lot about Linux and am thankful to both communities. Thanks to rasat for setting up the Wiki.

2. Installing CUPS

2.1 Packages

The following packages will be needed:

* CUPS - The actual CUPS software * Ghostscript - An interpreter for the Postscript language

       * One of the below driver packages (if unsure install Gimp-Print)

Packages::

* Foomatic (and all its dependencies and related software) - \"Foomatic is a database-driven system for integrating free software printer drivers with common spoolers under Unix\" * Gimp-Print - A collection of \"High quality drivers for Canon, Epson, Lexmark, Sony, Olympus, and PCL printers for use with Ghostscript, CUPS, Foomatic, and the Gimp.\" * Samba - File and printer sharing software for use with Windows * HPIJS - \"HP Linux inkjet driver. Provides support for DeskJet, OfficeJet, Photosmart, Business Inkjet and some LaserJet printer models.\" * CUPS-PDF - A nice package that allows one to setup a virtual PDF Printer that generates a PDF out of anything sent to it.

For sure, you will want to install the CUPS and Ghostscript packages. If you are not quite sure about what you are doing, I recommend that you install the foomatic and gimp-print packages, although they may not be needed. Samba is only needed if the system is to be connected to a networked printer using the samba protocol or if the system is to be a print server for Windows clients.

2.2 Using Pacman

For the rest of this document, you will be required to have root access. So either login in as root, or use the su command to switch to the root account. You will be required to use some sort of terminal program or the console to issue commands.

First let's update our software package repository:

       <verbatim>

# pacman -Sy

       </verbatim>

Next, let's install CUPS and Ghost view:

       <verbatim>

# pacman -S cups # pacman -S ghostscript

       #       pacman -S gimp-print (other another diver package)
       </verbatim>

That's it for the needed packages! (The power and beauty of pacman). If you want, you can also install the other optional packages now by using the command pacman -S pkgname where pkgname refers to any of the following packges: foomatic, gimp-print, samba, or hpijs.

In my case, I installed cups, ghostscript, foomatic, gimp-print and samba as I wasn't sure what I needed and I wanted to share my printer with my roommates across our network.

2.3 Download Printer PPD

(Depending on your printer, this step may be optional)

Now, we will download the PPD (Postscript Printer Description?) file for you printer. Here's an explanation of what a PPD file is from the Linux Printing website: \"For every PostScript printer the manufacturers provide a PPD file which contains all printer-specific information about the particular printer model: Basic printer capabilities as whether the printer is a color printer, fonts, PostScript level, etc., and especially the user-adjustable options, as paper size, resolution, etc.\" This step is optional and may not be needed as the standard CUPS installation already comes with quite a few PPD files. Moreover, the foomatic-filters or gimp-print packages already include quite a few PPD files which will automatically be detected by CUPS when you start it up.

To get the PPD file, go to the following website:

http://www.linuxprinting.org/printer_list.cgi

and select the manufacturer and model of your printer. After pressing the show button you will be presented with a page that had information about how well your printer is supported on Linux, what driver to use, and a link to the PPD file you should use. Go ahead and download the PPD file. Now, you will need to move the file to the cups folder so it can detect the file. If you are in the folder where you downloaded the PPD file, you can use the following command:

       <verbatim>

# mv your_printer.ppd /usr/share/cups/model/

       </verbatim>

For my setup, I had a Samsung ML-1250 laser printer, so I chose Samsung from the Linux Printing website dropdown box and then ML-1250 from the next one. I moved the file by using the following command:

       <verbatim>

# mv Samsung-ML-1250-pxlmono.ppd /usr/share/cups/model/

       </verbatim>

If you cannot find your printer in the website, you may want to look into related models or using generic printer drivers. For instance, back at home (I'm at university right now), I have a Samsung ML-1430 laser printer, which is not listed. Fortunately, the ML-1430 was compatible with the ML-1210 PPD file and drivers, so I just used that. Just do some googling or ask your manufacturer (good luck with that...).

If you used the HPIJS package, you probably do not need to download a PPD file, though you may want to. This may also apply to other proprietary or vendor supplied packages.

3. Configuring Cups

3.1 Options

Now that you have cups installed, you have a variety of options on how to setup CUPS. You can always use the tried and true command line. Likewise, various desktop environments such as Gnome and KDE have useful programs that can help you manage your printers. However, in order to make this process easy for the largest amount of users, we will use the web interface provided by CUPS.

Please note that if you are planning on connecting to a network printer, rather than one that is directly connected to your computer, you may wish to jump to the Printer Sharing section first. Linux to Linux printer sharing is quite easy and involves very little configuration. Windows to Linux and visa versa requires a little bit more effort, but is relatively easy as well.

3.2 Kernel Modules

Before we can use the CUPS web interface, we must install the appropriate kernel modules. The following are steps that I got from the Gentoo Printing Guide. If you are using a USB printer and a 2.4.x kernel, use the following command:

       <verbatim>

# modprobe printer

       </verbatim>

If you want to use a USB printer with a 2.6.x kernel, use the following command:

       <verbatim>

# modprobe usblp

       </verbatim>

Note, this assumes that you are using the stock kernels from Arch Linux. If you custom-rolled your own, you may need to run this first:

       <verbatim>

# modprobe usbcore

       </verbatim>
       Once you have the modules installed, you should plug in your printer and check if the kernel detected it by running the following:
       <verbatim>

# tail /var/log/messages

       </verbatim>

You should see something like this:

       <verbatim>

# Feb 19 20:17:11 kernel: printer.c: usblp0: USB Bidirectional

               printer dev 2 if 0 alt 0 proto 2 vid 0x04E8 pid 0x300E

Feb 19 20:17:11 kernel: usb.c: usblp driver claimed interface cfef3920 Feb 19 20:17:11 kernel: printer.c: v0.13: USB Printer Device Class driver

       </verbatim>

If you plan on using a parallel port printer, the configuration is pretty much the same. Kernel 2.6.x users have to first type in:

       <verbatim>

# modprobe lp

       </verbatim>

And then both 2.4.x and 2.6.x kernel users can enter in:

       <verbatim>

# modprobe parport # modprobe parport_pc

       </verbatim>

Once again, you can check your setup by running the tail command specified above. You should see something like this:

       <verbatim>

# lp0: using parport0 (polling).

       </verbatim>

Please note that I only have a USB printer and can only verify that the USB procedure works. The parallel port procedure should also work, but I cannot guarantee it.

You may also want to have the system automatically load the kernel module every time the computer starts up. To do this use your favorite text editor to open up /etc/rc.conf and add the appropriate module to the MODULES=() line. Here's a portion of the text from my rc.conf file:

       <verbatim>

MODULES=(!usbserial scsimod sdmod snd-ymfpci snd-pcm-oss printer ide-scsi)

       </verbatim>

3.3 CUPS Daemon

With the kernel modules installed, you are now ready to start the actual CUPS daemon. To do this, simply run this command:

       <verbatim>

# /etc/rc.d/cups start

       </verbatim>

If you want to have cups start up automatically every time you start your computer, than you need to add it to your DAEMONS=() line in the /etc/rc.conf file. For example:

       <verbatim>

# DAEMONS=(pcmcia syslogd klogd !fam esd mono network autofs cups crond gdm)

       </verbatim>

3.4 Web Interface and tool kit.

Once the daemon is running, if a web interface is available. Open up your browser and go to:

http://localhost:631

or install \"Gnome Cups Manager\" tool kit (see Appendix: A.1 Alternative CUPS Interfaces)

From here, all you have to do is follow the various wizards to add your printer. To setup my Samsung ML-1250 printer, I started out by click on Manage Printers, and then Add Printer. I was then prompted for a username and password. I just logged in as root. I entered in ml1250 for my printer name, My Room for location and then Peter's Samsung ML-1250 Laster Printer for description. Next you will select the device. Since my printer is a USB device, I just selected USB Printer #1. The name of my printer also showed up next to the label USB Printer #1, so look for that. Next, I simply chose the appropriate drivers and the installation was complete.

Once the installation is complete, you can test your configuration by pressing the Print Test Page button.

4. Printer Sharing

4.1 Linux to 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:

       <verbatim>

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

       </verbatim>

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

       <verbatim>

# /etc/rc.d/cups restart

       </verbatim>

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 editted this line:

       <verbatim>

ServerName beast

       </verbatim>

Next, run the following command to update the client computer:

       <verbatim>

# lpq

       </verbatim>

You should see something like this:

       <verbatim>

# ml1250 is ready no entries

       </verbatim>

There are more configuartion possibilities including an automatic configuration which are described in detail on http://localhost:631/sam.html#CLIENT_SETUP (this link works on your printer server).

That's it for Linux to Linux printer sharing.

4.2 Linux to Windows

If you are connection to 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 enter in the web interface as specified in section 3.3 and 3.4. Before this though, you need to activate the Samba CUPS backend. You can do this by entering in the following command:

       <verbatim>

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

       </verbatim>

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 in:

       <verbatim>

smb://username:password@hostname/printer_name

       </verbatim>
       Or without a password:
       <verbatim>
       smb://username@hostname/printer_name
       </verbatim>

Make sure that the user actually has access to the printer on Windows computer. Select the appropriate drivers and that's about it.

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


4.3 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:

       <verbatim>

global workgroup = Heroes server string = Arch Linux Print Server security = user

printers

  	comment = All Printers
  	path = /var/spool/samba
  	browseable = yes

# to allow user 'guest account' to print.

  	guest ok = no
  	writable = no
  	printable = yes
  	create mode = 0700
  	write list = @adm root neocephas
       </verbatim>

That should be enough to share your printer, but you just might want to add an individual printer entry:

       <verbatim>

ML1250

	comment = Samsung ML-1250 Laser Printer
  	printer=ml1250
  	path = /var/spool/samba
  	printing = cups
  	printable = yes
  	printer admin = @admin root neocephas
  	user client driver = yes
  	# to allow user 'guest account' to print.
  	guest ok = no
  	writable = no
  	write list = @adm root neocephas
  	valid users = @adm root neocephas
       </verbatim>

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:

       <verbatim>

# useradd neocephas # smbpasswd -a neocephas

       </verbatim>

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

       <verbatim>

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

       </verbatim>
      The next items that need changing are /etc/cups/mime.convs and /etc/cups/mime.types:
      mime.convs:
      <verbatim>
      # The following line is found at near the end of the file. Uncomment it.
      application/octet-stream        application/vnd.cups-raw        0       -
      </verbatim>
      mime.types:
      <verbatim>
      # Again near the end of the file.
      application/octet-stream
      </verbatim>
      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:
       <verbatim>

# /etc/rc.d/samba restart

       </verbatim>

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.

4.4 Windows 2000 and Windows XP to Linux

For the most modern flavours 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:

http://hostipaddress:631/printers/printer_name

where hostipaddress 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.

4.5 Others to Linux, Linux to others

More information on interfacing CUPS with other printing systems can be found in the CUPS manual, e.g. on http://localhost:631/sam.html#PRINTING_OTHER

A. Appendix

A.1 Alternative CUPS Interfaces

If you are a GNOME user, you can manager and configure your printer by using the gnome-cups-manager. You can get this package for Arch Linux from the Staging Repository at:

http://xentac.net/tur

KDE users can modify their printers from the Control Center. Both should refer the those desktop environments' documentation for more information on how to use the interfaces.

A.2 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.

A.3 Online Resources

Here is a listing of websites that may be of use to you:

* Official CUPS documentation on your computer http://localhost:631/documentation.html * Official CUPS Website - http://www.cups.org/ * Linux Printing - http://www.linuxprinting.org/ * Tips and Suggestions on common CUPS problems - http://home.nyc.rr.com/computertaijutsu/cups.html * Gentoo's Printing Guide - http://www.gentoo.org/doc/en/printing-howto.xml * Arch Linux User Forums - http://bbs.archlinux.org/

A.4 Specialized Cases

This section is dedicated to specific problems and solutions as I come across them. If you wish to add your own case, please email me and I will be sure to put it here.

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

A guest on the Arch Linux BBS suggests that one install the pnm2ppa printer filter for the HP Deskjet 700 series. Without this the print jobs will be aborted by the system. A pkgbuild can for pnm2ppa can be found at

http://bbs.archlinux.org/viewtopic.php?t1054&highlightpnm2ppa

A.5 Another Source for Printerdriver

       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.