lpd: Getting the Hard Copy
In the 16th century, the printing press opened up a whole new world of communications. Print was the first mass communications medium, paving the way for books, magazines, newspapers and all the other amenities of this generation. Although we live in a world dominated by computers and electronics, the printing press still plays an important role in our everyday lives. This fact is especially apparent if you are reading the print version of this magazine.
Today, the power of the printing press is available to the individual. Computers, printers and copy machines allow virtually anyone to communicate effectively to any number of people. Better still, it's easier and cheaper than ever.
One of the most common questions asked by newcomers to the Linux world is how to get their printers working with Linux. There are, in actuality, a few different ways to accomplish this task. First, however, you must enable lp support in the kernel and recompile. This is done in most kernels already. To check if your kernel is ready, plug your printer in and watch your kernel startup messages. If you see references to lp0 or lp1, your kernel is configured for parallel printing.
The most primitive way to print a text file is simply to use the cat command to send it to the printer at /dev/lp1:
cat filename.txt > /dev/lp1
This will catenate the file (in this case, filename.txt) to /dev/lp1, your printer device. Replace /dev/lp1 with the device name of your printer, if it is different.
The main problem with printing text files this way is that most people get the dreaded “staircase” effect. It makes the printed text look
Something Like This.
This is not acceptable, so most people use lpd (line printer daemon) to print files. If you don't have lpd already installed, it is obtainable from ftp://metalab.unc.edu/pub/Linux/system/printing/ as the lpr-linux package. Once you have downloaded and installed the software, you can add the following lines to one of your startup scripts, in order to start lpd when the system boots.
if [ -f /usr/sbin/lpd ]; then echo -n "Starting lpd..." /usr/sbin/lpd fiYou might want to replace the path to lpd with your custom path.
However, running lpd alone isn't very useful. All it actually does is facilitate the queueing of print jobs. It does no translating or converting—that's why print filters are used. As you may know, many Linux and X applications can output and print to PostScript. This includes Netscape and the GIMP. To take advantage of these powerful applications and many others, you have to install a filter for your specific printer. Several different printer filter packages are available, so almost all popular printers are supported.
To install a filter, the first thing you must do is download the one you want. Many filters are available from the Sunsite Linux archives at ftp://metalab.unc.edu/pub/Linux/system/printing/.
The most popular print filters are apsfilter and magicfilter. In addition to the major print filters, there are many small converters and translators as well as other printer filters available for download at metalab. After you have downloaded the package you want, just follow the directions provided and install the package. (Note that metalab.unc.edu used to be sunsite.unc.edu.)
Now comes the tricky part. The lpd software reads from a configuration file called the printcap, or printer capability database. The printcap is a simple text file that holds the information necessary for lpd to output to printers. It has vast capabilities and options, but we're going to edit it in only the simplest ways right now. Fire up your favorite text editor and open the file /etc/printcap. If there is text currently in the file, make sure you don't need it (it's all commented and annotated), and comment out unneeded lines by placing a # symbol in front of the first character of those lines.
At this point, you are ready to start entering printer information into the file. Make sure you have installed your print filter correctly before proceeding.
Append this one line to your /etc/printcap file:
First, replace name with the name of your printer. Second, replace lpx with the device name of your printer, which is probably lp1. Finally, replace /path_to/print_filter with the actual path to your print filter. You must remember to change the permissions of your installed print filter so that it is executable and readable. Simply type:
chmod 755 /Also, make sure the print spool directory, /var/spool/lpd, exists. If you want to print to a remote printer on another UNIX machine, set up the printer on that machine, then append (don't start a new line)
rm=remotehost:rp=remoteprinter:to the previous /etc/printcap entry shown above. If you decide to do this, however, replace :lp=/dev/lpx: with a plain :lp=:. For more options to put in the printcap file, look at the man page for printcap (type man printcap at the prompt).
Now, restart lpd by issuing the following command:
killall -HUP lpd
There should be a brief pause, then you will be dropped back to a command prompt. If you've followed these directions correctly, do a test print: fire up Netscape and print a test page. Click on the File menu and select “Print” or “Print Frame”. Make sure the Print Command field is set to
lpr -Of course, replace printername with the name you gave your printer in /etc/printcap. There is no space between the -P and printername. To print text files, you can open them up in a program that is printer-aware (such as Netscape), or you can type the following on a command line:
lpr -Replace printername with the printer's name and replace filename with the name of the file you want to print. At this point, if all went according to plan, there should be a nicely printed piece of paper on your printer.
Win an iPhone 6
Enter to Win
|December 2015 Video Preview||Nov 30, 2015|
|Take Control of Your PC with UEFI Secure Boot||Nov 30, 2015|
|Geek Hide-away in Guatemala - Stay for Free!||Nov 26, 2015|
|Microsoft and Linux: True Romance or Toxic Love?||Nov 25, 2015|
|Non-Linux FOSS: Install Windows? Yeah, Open Source Can Do That.||Nov 24, 2015|
|Cipher Security: How to harden TLS and SSH||Nov 23, 2015|
- Take Control of Your PC with UEFI Secure Boot
- Cipher Security: How to harden TLS and SSH
- Non-Linux FOSS: Install Windows? Yeah, Open Source Can Do That.
- Web Stores Held Hostage
- Firefox's New Feature for Tighter Security
- Microsoft and Linux: True Romance or Toxic Love?
- PuppetLabs Introduces Application Orchestration
- Geek Hide-away in Guatemala - Stay for Free!
- diff -u: What's New in Kernel Development
- IBM LinuxONE Provides New Options for Linux Deployment