lpd: Getting the Hard Copy

 in
How to set up local and networked printing services in Linux.
Sharing Your Printers

Now that you have your printer set up for yourself, you might want to consider sharing it with the rest of the network. There are a few ways of doing this. With other UNIX or Linux machines with BSD-styled print systems, just follow the directions in the previous section, and you'll be off and running. Pay attention to the specified network configuration line.

The most likely scenario, however, is one Linux machine sharing its printer or printers with one or more Windows machines. To do this, you're going to want to use Samba, the SMB implementation for UNIX, which runs quite well on Linux. After you have finished setting up the printers, install Samba on the Linux machine. Samba is available at http://www.samba.org/ and is open-source software as well.

Read through the Samba documentation to get it installed. It's a quick install, but it does require some editing of configuration files. For those of you who are impatient, here's a simple configuration file to use (locate it at /usr/local/samba/lib/smb.conf):

[global]
   remote announce = 192.168.1.255
   interfaces = 192.168.1.1/255.255.255.0
   netbios name = your_computer_name
   workgroup = your_workgroup_name
   printing = bsd
   security = share
[public]
   comment = Public Stuff
   path = /tmp
   public = yes
   writable = yes

This will export one share for use on the network, named “public”. If you have the Win95 machines set up with the same parameters, you should be able to browse the public share and look through all of its subdirectories.

Once that is done, you're ready to add the printer. The printer is added to the config file in the following manner:

[printername]
   path = /
   printer name =
   writable = yes
   public = yes
   printable = yes
   print command = lpr -Pprintername %s; rm %s

Replace printer_spool_dir with the printer's spool directory (I just use /tmp, but you can use /var/spool/lpd/ if you wish) and printername with the name of your printer (I just used hp).

At this point, restart Samba:

killall -HUP nmbd; killall -HUP smbd

Make sure you can still browse files across the network. This time, you should see a printer icon with the assigned name from the Samba configuration file.

On the Win95 clients, it would be best to install a generic PostScript printer. Then all your Win95 programs will output PostScript, and the printer filter on your Linux server will be able to both spool and print your documents as if they were local documents. To add a network printer in Win95, select the “Network” option when the Add Printer script prompts you. However, this approach doesn't always work, and you might want to use a more crude way of printing by changing the print command line in the above config file snippet to the following:

print command = cat %s > /dev/lp1; rm %s

Replace /dev/lp1 with the device to which your printer is attached. After you have replaced that line, re-install the printer on your Win95 box as the actual type; i.e., if you have a LaserJet 4L, install it as a LaserJet 4L in Win95. Note that with this method, no print spooling will take place on the Linux machine.

Wrapping Up

I hope this tutorial has helped you set up printing services in Linux. If you're fortunate enough to have a network in your home or office, you should also be able to set up the printer in question for use on the network by other computers. If you're still having trouble printing, you can check out the Linux Printing-HOWTO located at metalab.unc.edu/LDP/HOWTO/Printing-HOWTO.html. Good luck!

Michael Hughes is an honors student living in Thousand Oaks, California. His hobbies include Perl programming and snowboarding, as well as administering computers running Linux. He can be reached via e-mail at mfh@psilord.com.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix