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.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- SourceClear Open
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Tech Tip: Really Simple HTTP Server with Python
- Parsing an RSS News Feed with a Bash Script
- Doing for User Space What We Did for Kernel Space
- Managing Linux Using Puppet
- Returning Values from Bash Functions
- SuperTuxKart 0.9.2 Released
- Non-Linux FOSS: Caffeine!
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide