31,19 €
In Detail
The Common UNIX Printing System (CUPS) is software that allows a computer to act as a print server, receiving print jobs from client computers, managing them, and sending them to the appropriate printer. It consists of a print spooler and scheduler, filters to convert print jobs to the format required by each printer, and a backend system to send the data to the chosen printer from client applications. Since every printer manufacturer does things differently, printing can be very complicated, and has always been a hard issue in the UNIX world for this reason. By providing a portable, modular printing layer, CUPS brings printing for UNIX into the modern age. It applies open standards for network printing through the Internet Printing Protocol (IPP) and uses platform-independent drivers (Postscript Printer Definition, PPD) to print. Today, CUPS is the default printing system for a large number of Linux distributions (Ubuntu, Fedora, etc.) and UNIX-based operating systems.
This book assumes that you have no knowledge of CUPS. It starts by telling you the story of how CUPS came to be and why there is such excitement about it. We then move on to installing, compiling, and managing your print network. Haven't you struggled to find the right directives for your printer? Enough of that search, this book will tell you where to find what. Not only that, but widely used directives and their uses are explained here along with directions to use them. There is more: you can learn how to manage the ever increasing print job load, set up your clients, and manage users. All this done, you will learn how to monitor, filter, and secure your CUPS server.
A practical tutorial to installing, managing, and securing this powerful printing system
Approach
This book takes a tutorial approach and each chapter contains step-wise instructions to perform specific tasks.
Who this book is for
This book is for Linux/Unix System Administrators interested in designing and setting up a CUPS network and provides enough knowledge to understand how the technology works, make decisions about deployment, and then implement a stable work environment. No knowledge in CUPS is required but readers need to be comfortable with working in the Linux/Unix environment. On the whole, readers should have basic knowledge of the Linux environment.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 255
Veröffentlichungsjahr: 2008
Copyright © 2008 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2008
Production Reference: 1190908
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-84719-258-5
www.packtpub.com
Cover Image by Vinayak Chittar (<[email protected]>)
Author
Ankur Shah
Reviewer
Aric Pedersen
Acquisition Editor
Rashmi Phadnis
Technical Editor
Gagandeep Singh
Copy Editor
Sumathi Sridhar
Editorial Team Leader
Akshara Aware
Project Manager
Abhijeet Deobhakta
Project Coordinator
Lata Basantani
Indexer
Monica Ajmera
Proofreaders
Claire Lane
Chris Smith
Production Coordinator
Shantanu Zagade
Cover Work
Shantanu Zagade
Ankur Shah has been working with Linux/AIX for the last four years as a System Administrator. His previous assignment was with Packt Publishing, where he worked as System Administrator and also started implementing CUPS. He completed his graduation in Computer Engineering from Nagpur University, India. He is currently working as a SAP Basis Administrator and also started working on Governance Risk and Compliance for access Control. He is also interested in Oracle Database Administration and Security.
He is the biggest fan of Kajol. The day her movie releases is a day of celebration for him and he only parties once a year—5th August—that's Kajol's birthday. It goes without saying that he watches all her movies several times—often dragging his friends and family to participate in his madness.
Mummy, Papa, and Nani—thanks for your love and support. Even though I am not with you all the time, you are always there in my heart.
I would like to thank Vicky, Dhruti, Sunilkumar, Harde, Vevayji, Vevanji, Rakeshbhai, Ravibhai, and Buntybhai.
I would like to remember Bipinkaka who passed away this year. He was someone I admired a lot.
Thanks to Sarojkaki, Ujwal, Leniya, Amitkumar, Binita, Priteshkumar, Moksha, Motapapa, Motimummy, Mamtaben, Nilesh Jiju, Kalpeshbhai, Reenabhabhi, Hirenbhai, Bhavibhabhi, Akasha, Sagar, Urvi, Babulafuva, Pushpafoya, Jayben, Nareshjiju, Dhansukhbhai, Tarabhabhi, Guddi, Mayurkumar, Pintoo, Bablu, Kinjal, Praveenfuva, Hansafoya, Pankajiju, Alpaben,,Pankaj bhai, Sangeetabhabhi, Leenabe, Manjojiju, Bimalbhai, Komalbhabhi, Kinjal, Chiku, Amar, Jheel, Viral,Krish, Rujul, Kushi, Vidulamasi, Masaji, Ripalbhai, Bhabhi, Chitan, Pinkiben and her family, and all my other relatives not mentioned here due to lack of space.
I would also like to remember all my neighbors and friends: Dr Uncle, Nayna Aunty, Jigar, Trusha, Babu, Gaugang, Rahul, Tinuben and their parents, Kalpesh Sir, Shailesh and his family, Shashikant Sir and his family, Kavitaben and her family.
All my college friends Jignesh, Manish, Sandeep, Parag, Mausam, Prashant, Jaydeep, Jigar, Tapan, Shaunak, Divyesh, Nirav, Pritesh, Deepak, Lokesh. Thanks also to Aarti, Vushal, Amit, Ajit, Ramesh, Kaiser, Vinod, Kailash, Umesh, Rajendra, Digambar, Sandeep, Arun, Vikat.
A big token of gratitude to Ninad Sir from Interpole Technologies who was the reason I started working on Linux.
Many, many thanks to Dipali—she has always been there to support and guide me.
I can’t let this opportunity pass without mentioning my ex-colleagues at Packt—Sandeep, Shelly, Manjiri, Jimmy, Priyanka, Tripti, Shravani, Teerth, Manu and their friends Nikhil da Dawggie and Ved da Prakash Jha, Raj, Bansari, Saurabh, Sagara, Tints, Ritika, Zenab, Aboli, Devdoot Naidu, Girish, and Rajeev (thanks a lot buddy).
Thanks to Packt where I found so many of my friends—Lata, Poochi, Monica, Shantanu, Nilpreet, Patricia, Sumathi, my previous AEs (Nanda, Viraj, and Shayantani), Silpa <3 Sameer, Rameshbhau, Harshada, Neelanchal, Swarna, Ajay, Swapna, Akshara, Mithil, Abhijeet, and Bhushan.
Special thanks to Rupaldee and Mineshjiju (with whom I have been living for the last four years), Dada/Dadi who have treated me like a son, Mudra my niece and Chandra my nephew (two of my favorite chelas), Mayankjiju, Neetaben, Bimaljiju, Chhayaben, Prakashjiju, Nimishaben, Vevayji, Vama, Dhara, Labdhi, Reeti, Mitwa, and Jainam.
Thanks to all my neighbors at Mumbai—Pradeepmasa, Masi, Ruchi, Snehalbhai, Masa-Masi, Nehadidi, Pradeepbhaiya, Niyatididi, Heet, Anushka, and Bhavya.
Louay Fatoohi—for believing in me and giving me the opportunity to work on this book.
Special thanks to Rashmi—she always believed in me and without her this book would never have been completed.
And finally the real architect of this book, Aric Pedersen. VPJ was right when he said, Author book thode hi na banata hai, reviewer banata hai. Aric is everything that the open source culture stands for. He is a great guy to work with and I wish the world is overrun with his clones.
Aric Pedersen is the author of cPanel User Guide and Tutorial (978-1-904811-92-3) and Web Host Manager Administration Guide (978-1-904811-50-3) both written for Packt Publications. He has over 8 years experience serving as a systems administrator. He also works for Netenberg.com, creators of Fantastico, the first and most popular web script autoinstaller for cPanel servers.
Kajol, this book is dedicated to you. You have always been my inspiration since the day I watched DDLJ for the first time. I know you like reading books and this is the only one I could write.
The Common UNIX Printing System (CUPS) that is provided under the GNU General Public License (GPL) and GNU Library General Public License (LGPL), Version 2, allows you to print from applications such as the web browser. CUPS uses the Internet Printing Protocol (IPP) for managing print jobs, print queues, and it adds network printer browsing and PostScript Printer Description-based printing options. CUPS was first developed by Easy Software Products, but it is currently owned and maintained by Apple Inc.
CUPS converts the page descriptions produced by your application (put a paragraph here, draw a line there, and so forth) into something your printer can understand, and then sends the information to the printer for printing.
Now, since every printer manufacturer does things differently, printing can be very complicated. CUPS does its best to hide this from you and your application so that you can concentrate more on printing and less on how to print. Generally, the only time you need to know anything about your printer is when you use it for the first time, and even then, CUPS can often figure things out on its own.
Chapter 1 covers the history of UNIX printing systems which includes traditional printing systems such as Berkeley printing system and System V printing System. We will also cover how CUPS evolves as a printing system, along with the architecture of CUPS.
Chapter 2 checks the pre-requisites for downloading and installing CUPS software. It also includes restarting CUPS service and accessing it via web interface.
Chapter 3 discusses the printer drivers that CUPS supports. We will also see how to manage printers and jobs using the Command-Line Tool (lpadmin) and the Web GUI Interface. This will include how to add, modify, delete, stop, and share printers, setting up options on printers, and how to cancel, move, restart jobs, and so on.
Chapter 4 looks at how to group multiple printers (printer classes), and how to manage them using the command-line tool and the web interface as in the previous chapter.
Chapter 5 covers the topic of system requirements for a CUPS print server. This chapter mainly discusses the server configuration file cupsd.conf and its directives, and the configuration files for printers (printers.conf), and classes (classes.conf).
Chapter 6 looks at setting up a client on various platforms such as UNIX/Linux, Windows, and Mac OS X using protocols such as LPD (Line Printer Demon), IPP (Internet Printing Protocol), and SMB (Server Message Block). It also has a section on how to use printer setups along with other printing systems.
Chapter 7 covers how we set up quotas on all CUPS users using the command-line tool, and an overview of the page_log file. This chapter also covers other accounting tools that can work with CUPS. Here, we discuss PyKota in detail.
Chapter 8 looks at monitoring CUPS using the lpstat command, and has an overview of the access_log and the error_log files. We will also see how Simple Network Management Protocol (SNMP) helps CUPS discover the printer and help other networking tools such as Cacti in managing printers.
Chapter 9covers an overview of how CUPS recognizes different file formats with the help of the mime.types file. This chapter also covers how CUPS uses various filters to convert one file format into another specified in the mime.convs file.
Chapter 10 looks at how TCP/IP printers can be managed. This will also cover the support of encryption and various authentication methods such as basic, digest, and Kerberos. This chapter will also cover the topic on a possible Denial of Service (DoS) that can occur in CUPS.
To get the most from this book you will need a copy of the CUPS server software and one or more PCs on which to install it. You will need the ability to run UNIX/Linux commands to install the software. You will need a printer with drivers for that printer.
Printers in CUPS can be managed either via a command line or a web interface. This web interface can work on almost any web browser including Firefox, Safari, or the Internet Explorer. Here it is assumed that the reader has a basic knowledge of using the browser software. Since CUPS can also work across a local network/the Internet, you will need a network/Internet and a separate client PC, if you want to use this feature.
Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply drop an email to <[email protected]>, making sure to mention the book title in the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email <[email protected]>.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide the location address or website name immediately so we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with some aspect of the book, and we will do our best to address it.
CUPS is the abbreviation for Common UNIX Printing System. It is a modularized computer printing system for UNIX-like operating systems, which provides a common printing interface across a local network, masking differences among the printing systems on each computer. A computer running CUPS is a host that can accept print jobs from client computers, process them, and send them to the appropriate printer. It was developed by Easy Software Products (ESP) and is now owned and maintained by Apple Inc. Now CUPS is the standard printing system in most Linux distributions.
Common UNIX Printing System (CUPS) is the base for streamlined printing systems for Mac OS X. CUPS can also work independently on Mac OS X. You can get more information on this at:
http://developer.apple.com/printing/overview.html
In this chapter, we will discuss the various features of CUPS, and the support of PostScript Printer Driver (PPD) in detail.
CUPS consists of a print spooler and a scheduler, a filter system that converts the print data to a format that the printer will understand, and a backend system that sends this data to the print device.
CUPS uses the Internet Printing Protocol (PP) to manage print jobs and queues. It also provides the traditional System V and Berkeley command line interfaces. It also provides limited support for the Server Message Block (SMB) protocol.The device drivers supplied by CUPS are based on PostScript Printer Description (PPD) files. There are a number of user interfaces for different computing platforms that can configure CUPS, and it has a built-in, web-based interface.
In the early versions of UNIX, the line printer daemon (LPD) was used to spool text to a printer. This LPD also known as Berkeley printing system (BSD) is able to send any kind of file to a printer.
The model of this printing system consists of the following features:
The biggest disadvantage with the Berkeley printing system is that it doesn't provide any feature for print jobs and filtering systems. These features were added in a new line printer (LP) system. The following URL shows information about this system in detail:
http://tools.ietf.org/html/rfc1179
A printer that supports LPD/LPR is sometimes referred to as a "TCP/IP printer". The LPD/LPR protocol listens on TCP port 515.
The System V printing system is one of the several standard architectures for printing on the UNIX platform which uses the lp command. The following are some of the features of System V printing system:
OpenSolaris is an open source project created by Sun Microsystems to build a developer community around Solaris Operating System technology. You can get more information on this at: http://opensolaris.org/os/
CUPS emulates both System V and Berkeley print architectures at the interface level, though its internal architecture is different from both. We will see the architecture of CUPS with its features shortly.
Early personal computers, such as the ones from IBM, and printers only handled text. So they worked in a fashion similar to the UNIX mainframes of that time. Each application came with its own code to handle text-based printing to popular printers. Most of those applications are shipped with modules that help users print to their specific printers.
As the technology improved, printers began to support graphics, so applications had to adapt support the expanded printer features. The complexity of the software used to communicate with printers soon began to rival the applications themselves, and it wasn't long before that these "printer drivers" were an industry of their own. Unfortunately, a printer driver for one application rarely worked with another, so the applications had to adapt support the expanded printer features.
Apple's release of the Macintosh computer changed the manner in which printing was done on the personal computer. Designed from the beginning to be a desktop publishing system, the Macintosh abstracted the printing interface from the application. Applications only had to tell the printing system where and what to print, and the printing system would translate that request into the desired output on the selected printer. Printer drivers were provided with the Mac OS or with the printer you purchased for your computer. The same driver supported all Mac OS applications. Arguably, the Mac OS has dominated desktop publishing since its inception. To this day, a large number of printing shops use the Mac OS for their work.
Microsoft's first Windows operating environment duplicated this paradigm. The printing and information display systems are nothing alike, technically. However, to an end user, they seem to work similarly. Applications for these operating systems were able to produce professional-quality output with a generic printing interface. Yet until recently, UNIX only had a print file spooling system.
In 1993, a company called Easy Software Products (ESP) was started, aimed at supporting the Digital UNIX and Linux operating systems. Unfortunately, these operating systems used the original LPD for printing, so you couldn't pass options to the printer drivers. This alone would cripple any drivers you could develop. To make matters more complicated, at least three versions of the LPD were in common use, and they were not 100% compatible with each other.
The original design of the Common UNIX Printing System (CUPS) was based around the LPD network protocol. Later, developers added support for various features such as remote administration, and authentication when the Internet Printing Protocol (IPP) working group was created. The IPP working group originally was just going to update the LPD network protocol, but quickly changed direction to create a much more functional and extensible protocol that could evolve as needed to support new technologies.
CUPS provides a mechanism that allows print jobs to be sent to printers in a standard fashion. The data is sent to a scheduler, which then sends jobs to a filter system that converts the print job into a format which the printer will understand. The filter system then passes the data on to a backend—a special filter that sends print data to a device or a network connection.
The primary advantage of CUPS is that it is a standard and modularized printing system that can process numerous data formats on the print server. Previously, it was difficult to find a standardized solution that would allow numerous printers to print their full feature sets. For instance, the System V and Berkeley printing systems were largely incompatible with each other, and they required setting up complicated scripts and workarounds to convert from the program's data format to a format the printer understood. They often didn't know how to detect the file format that was being sent to the printer and thus could not convert data correctly. They also did their data conversion on the workstation and not on the server.
With CUPS, it is far easier for printer manufacturers and printer driver developers to create drivers that work natively on the print server than before. As the processing is done on the server, it is also easier to allow for network-based printing. Another advantage that CUPS has is that when it is used with Samba software, the printers can be used for remote print from and to Windows PCs.
Scheduler
The scheduler is a HTTP/1.1 server application that handles HTTP requests. Besides handling printer requests via IPP POST requests, the scheduler also acts as a full-featured web server for documentation, status monitoring, and administration. The scheduler also manages a list of available printers on the LAN and dispatches print jobs as needed using the appropriate filters and backends.
Configuration Files
The configuration files consist of:
The HTTP server configuration file is purposely similar to the Apache web server configuration file and defines all the access control properties for the server.
The printer and class definition files list the available printer queues and classes. Printer classes are collections of printers. Jobs sent to a class are forwarded to the first available printer in the class, in a round-robin fashion.
The MIME type files list the supported MIME (Multipurpose Internet Mail Extensions) types (text/plain, application/postscript, and so on) and the "magic" rules for automatically detecting the format of a file. These are used by the HTTP server to determine the Content-Type field for GET and HEAD requests and by the IPP request handler to determine the file type when a Print-Job or Send-File request is received with a document format of application/octet-stream.
The MIME conversion rule files list the available filters. The filters are used when a job is dispatched, so that an application can send a convenient file format to the printing system which then converts the document into a printable format as needed. Each filter has a relative cost associated with it, and the filtering algorithm chooses the set of filters that will convert the file to the needed format with the lowest total "cost".
The PPD files can describe the capabilities of all the printers, not just PostScript printers. There is one PPD file for each printer. PPD files for non-PostScript printers define additional filters through CUPS Filter attributes to support printer drivers.
CUPS API
The CUPS API contains CUPS-specific convenience functions for queuing print jobs, getting printer information, accessing resources via HTTP and IPP, and manipulating PPD files. Unlike the rest of CUPS, the CUPS API is provided under the terms of the GNU LGPL, so it may be used by non-GPL applications.
You can get detailed information on the license of CUPS and other supported software at: http://www.cups.org/documentation.php/license.html
Berkeley and System V Commands
CUPS provides the System V and Berkeley command-line interfaces for submitting jobs and checking the printer status. The lpstat and lpc status commands also show network printers ("printer server") when printer browsing is enabled.
The System V administration commands are supplied for managing printers and classes. The Berkeley printer administration tool (lpc) is only supported in a "read-only" mode to check the current status of the printer queues and the scheduler.
Filters
A filter program reads from the standard input or from a file if a filename is supplied, and then sends the output to the backend in a format the printer recognizes. The filters supports a common set of options including printer name, job ID, username, job title, number of copies, and job options. Filters are provided for many file formats and include image file and PostScript raster filters that support non−PostScript printers. Multiple filters are run in parallel to produce the required output format.
