- Table of Contents
- Copyright
- About the Lead Authors
- About the Contributing Authors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- I. Red Hat Linux Installation and User Services
- Chapter 1. Introduction to Red Hat Linux
- Chapter 2. Installation of Your Red Hat System
- Chapter 3. LILO and Other Boot Managers
- Chapter 4. Configuring the X Window System, Version 11
- Chapter 5. Window Managers
- Chapter 6. Connecting to the Internet
- Chapter 7. IRC, ICQ, and Chat Clients
- Chapter 8. Using Multimedia and Graphics Clients
- II. Configuring Services
- Chapter 9. System Startup and Shutdown
- Chapter 10. SMTP and Protocols
- Chapter 11. FTP
- Chapter 12. Apache Server
- Chapter 13. Internet News
- Chapter 14. Domain Name Service and Dynamic Host Configuration Protocol
- Chapter 15. NIS: Network Information Service
- Chapter 16. NFS: Network Filesystem
- Chapter 17. Samba
- III. System Administration and Management
- Chapter 18. Linux Filesystems, Disks, and Other Devices
- Chapter 19. Printing with Linux
- Chapter 20. TCP/IP Network Management
- Chapter 21. Linux System Administration
- Chapter 22. Backup and Restore
- Chapter 23. System Security
- IV. Red Hat Development and Productivity
- Chapter 24. Linux C/C++ Programming Tools
- Chapter 25. Shell Scripting
- Chapter 26. Automating Tasks
- Chapter 27. Configuring and Building Kernels
- Chapter 28. Emulators, Tools, and Window Clients
- V. Appendixes
- A. The Linux Documentation Project
- B. Top Linux Commands and Utilities
- C. The GNU General Public License
- D. Red Hat Linux RPM Package Listings
Linux Printing Commands
Of course, you don't have to use the printtool command to set up your printer. You can edit /etc/printcap directly, but you should know what you're doing and understand printcap's format. This file, an ASCII database of your system's local and networked printers, describes the capabilities of each printer in detail. For full details, see the printcap man page for commands and the termcap man page for the file's layout.
In fact, you can have multiple entries for each printer, which is helpful if you want to print different size papers, print color or black-and-white documents by switching cartridges, or change printer trays.
Old versions of Red Hat Linux used the 4.3BSD line-printer spooling system. This system has a number of features and associated programs to support background printing, multiple local and networked printers, and control of the printers and queued documents.
The main files used in the older printer spooling system were as follows:
/etc/printcap
/usr/sbin/lpd
/usr/sbin/lpc
/usr/bin/lpr
/usr/bin/lprm
/usr/bin/lpq
/dev/printer
These files provided the basic features needed to initiate and control print jobs from the command line. See Table 19.3 for a selected list of additional Linux commands you may find helpful when printing.
Red Hat Linux now uses Patrick Powell's LPRng print spooler software, which is descended from the 4.3BSD release but rewritten from the ground up. LPRng offers a host of benefits and features over the previous printer spooling software, such as being distributed under the GNU GPL, backward compatibility, security, diagnostics, and multiple printers on a single queue. In addition to the previously listed commands, LPRng also uses
/etc/lpd.conf
/usr/sbin/checkpc
/etc/lpd.perms
/usr/bin/lpstat
These additional files are used for site-specific settings, to check or fix LPRng's installation, to set permissions for users, and to report on a printer's status.
When you first boot Linux, the shell script, lpd (under /etc/rc.d/init.d/) starts lpd, the printer daemon. This program, a printer server, runs in the background and waits for print requests. When a request is detected on the print queue, the server connects to the designated printer and passes the document stream through the proper printer filter.
Print requests are started with the lpr command. For example, the following command line will print your document to a file in the /var/spool/lpd/lp directory using the printer named lp:
# lpr -Plp myfile.txt
Other print-spooling commands can help track your request. If you're printing a large document or a number of smaller files, you can see a list of print jobs running by using the lpq command. For example, to print a number of files at once to the default printer, use this:
# lpr *
Follow that command with this:
# lpq
This outputs the following:
Printer: lp@thinkpad Queue: 1 printable job Server: pid 3631 active Unspooler: pid 3632 active Status: processing 'dfB630thinkpad.home.org', size 1309, format 'f', IF filter 'filter'at 17:40:52.610 Rank Owner/ID Class Job Files Size Time active root@thinkpad+630 A 630 adsl,amd,anacron,apm 14542 17:40:51
This shows quite a bit of information, but the important item to note is the job number (630 in this example). If you want to stop the preceding print job, use the lprm command, followed by the job number, as in the following:
# lprm 630 Printer lp@thinkpad: checking perms 'root@thinkpad+630' dequeued 'root@thinkpad+630'
This shows that lprm has removed the spool files and stopped the job. To disable or enable a printer and its spooling queue, rearrange the order of any print jobs, or find out the status of printers, you can use lpc from the command line or interactively, but you must be logged in as root or as a superuser (through the su command).
LPRng's lpc command is very comprehensive and offers much more control over system and network printing than the legacy lpc command. This command may be used to activate or abort the print server, disable or enable print queuing, hold or release print jobs, and even move print jobs to a different printer! Start lpc on the command line like this:
# lpc
To view the built-in help on command keywords and syntax, type help or press ? like this:
lpc> help
After you press Enter, you'll see several pages of help text for lpc's 30 different commands. A more abbreviated command is LPRng's lpstat. Use the command like this:
# lpstat Printer: lp@thinkpad Queue: no printable jobs in queue Status: subserver pid 3632 exit status 'JABORT'at 17:43:05.111
If you have print jobs waiting, you'll see a list of jobs, along with information similar to that returned by lprm.
LPRng is documented through its commands' man pages and documentation under the /usr/share/doc/LPRng-3.6.22 directory. You'll find the latest version and documentation (including an excellent HOWTO document) at http://www.astart.com/lprng/LPRng.html.
Table 19.3. Selected Printing Commands
| Command | Description |
| cancel | LPRng utility to cancel print service |
| checkpc | Verifies and fixes LPRng print system files |
| lpc | Controls program for local and remote printers |
| lpd | LPRng print server daemon |
| lpf | General printer filter |
| lpr | Sends print jobs to printer queue |
| lprm | Controls print queue |
| lpstat | Displays specified print service status |
| mpage | Prints multiple pages of text per sheet |
| nprint | NetWare print client |
| pbm2ppa | Converts bitmap to HP PPA format |
| pbmto10x | Converts bitmap to Gemini printer graphic |
| pbmtoepson | Converts bitmap to Epson printer graphic |
| pbmtoppa | Converts bitmap to HP PPA format |
| pbmtoptx | Converts bitmap to Printronix printer graphic |
| pnm2ppa | Converts any map to HP PPA format |
| pqlist | Lists NetWare print queue |
| pqrm | Removes jobs from NetWare print queue |
| pqstat | Lists jobs in NetWare print queue |
| pr | Formats text files for printing |
| printmail | Formats mail messages for printing |
| pserver | NetWare print server |
| sliceprint | Formats documents with long lines |
| smbclient | Essential command used by smbprint for printing |
| smbprint | Shell script for printing to shared printers |
| testprns | Printer name check utility for Samba |
| tunelp | Parallel-port hardware utility |
Other Helpful Printer Programs and Filters | Next Section

Account Sign In
View your cart