November 25th, 2003, 16:17
Desktop FreeBSD Part 5: Printing
Ed Hurst 25 November 2003

================================================== ======================

The material that follows is drawn upon the work of "petie" at Sceaming
Electron <http://screamingelectron.org/phpBB2/>. [Keep in mind this is for broader publication.]

As a writer, the only reason I ever got that first computer was because
it was far more efficient than a typewriter, and certainly more
readable than my own handwriting. The sheer volume of what I've turned
out over the years would be impossible for me to manage on paper. Add
to that all the stuff written by others that I wanted to save, and it
boggles the mind. Still, most of what I've written is read by others on
paper. That means I have to translate my electronic files into readable
paper copies. That first computer would have been nearly useless to me
without the attached printer.

Open Source printing is one of the most powerful systems, yet remains
an ugly kludge in some ways. When multi-user computing was born,
printing was either from machines that were merely automated
typewriters ("raw" printers) or the work of fancy type-setting
printers. These two elements remain the heart of Open Source printing.
It is not built into the system, but is an add-on if you need it. I no
longer print very much, but when I do, it needs to be clean and

I recommended that during the process of installing FreeBSD, you add
the "ghostscript-gnu" package. That name "GhostScript" is another one
of those Open Source puns, where a freely available software project
mimics something proprietary and expensive, in function and in name.
Fancy printing with type-setting is handled via a formatting language
called PostScript, hence the name GhostScript. This is high-quality
stuff, folks. Documents formatted for printing by your writing software
are translated into the PostScript language, then sent to the printing
management system. The GhostScript program then translates that
document into whatever your printer understands. This makes high-end
type-setting available to the masses. All it needs is a driver that
GhostScript can use.

Depending on what sort of printer you have, there are two main systems
for creating this printer driver. If you run a dot-matrix printer, you
can get a driver quickly and easily with the "apsfilter" package for
FreeBSD. In fact, it is so simple I really don't need to outline it
here. After installing it, simply log in as root and type "apsfilter"
on the command line. The program will walk you through the process. If
you mess it up, run it again, and try different options. It's just not
that complicated, though you'll have to tolerate a humorous promotion
from the author of the program at the end. For most other printers,
it's best to use the new CUPS system.

CUPS was written to solve some problems with printing over a network,
and networking is the nature of most Open Source software. In the
process, solving those problems made possible a whole new class of
printer drivers that produce excellent results from ink-jet and
laser-jet type printers. If you run any distribution of Linux, it's
probably pretty easy to set up CUPS with some fancy GUI tool. In
keeping with the tradition that BSD is not for the masses, it's quite a
bit more complicated to get CUPS working. Still, we will ignore that
and forge ahead with these simplified instructions, which is what this
series is about.


First, we have to make sure all the proper software packages are
present. Here is a list of what you'll need:


That last one is usually already installed by default. One more package
is needed if you do anything with laser-jet printers: hpijs. As with
many things, if you choose to install these through the ports system,
you won't need to worry much about which package depends on another.
For example, if you simply install "cups" this way:

cd /usr/ports/print/cups/
make install

it will download, compile and install all three of the cups packages.
If you do the same for gimp-print, it will know to get the libijs
package on which it depends. The foomatic-db package needs curl. If you
try to install these as packages already built, you'll get a warning
when you try to install a package that depends on another that's

Can't find package xxxx!

or words to that effect. Then you will know precisely what's missing.
The exercise becomes more civilized if you learn at least one trick.
When you visit FreeBSD.org and look at the ports index, you will see at
the bottom of each package description a list of packages required to
build from source via ports. On the main page, on the left-hand column,
see the link "Ported Applications" under the "Software" heading.

Next, to really get the best driver for your printer, visit Linux
Printing. Click on this link to start the process:


Using the top row of boxes, click on the brand list, then the model list
and click the "Show" button on that line for your selected printer. The
next page will be filled with information about your printer and the
status of driver development. Usually there will be an obvious
recommendation for the best driver they can provide. For my Epson Color
Stylus 860, it was the "gimp-print-ijs" version. Directly to the right
of that recommendation is a few links for examining the driver, but I
know I want it and can use it, so I click the link that says, "download
PPD" and save it. The file name is long, but the file itself doesn't
take that long.

As root, copy the file to a specific directory in the CUPS system:
/usr/local/share/cups/model/. I suggest copying because it does two
things. First, it puts the proper permissions and ownership on the file
for the system's use. Secondly, it preserves a backup copy. I keep a
folder in my user account home directory called "bkup" just for this

There is one more package you will need to make things work really
well, and it must be obtained directly from the source provider at
Linux Printing: the "foomatic" package. We get the foomatic processing
helper files in their source code form. Click on this link to download


As root, copy this package to /usr/local/src/, which is the ideal
location for anything you add to your system that is not part of the
base installation. Open the package and build it:

gunzip foomatic-filters-3.0.0.tar.gz
tar -xvf foomatic-filters-3.0.0.tar
cd foomatic-filters-3.0.0

Until you learn more about why, just be sure you type the commands
exactly as shown. When the prompt comes back, two important files should
be there in the directory, "foomatic-rip" and "foomatic-gswrapper". Move
these two into the /usr/local/bin/ directory, and make sure they have
permissions that allow everyone to execute them (they are perl scripts).
Here's how to do that from the commandline:

mv foomatic-rip /usr/local/bin
mv foomatic-gswrapper /usr/local/bin
cd /usr/local/bin
chmod 755 foomatic-rip foomatic-gswrapper

Next, we will allow CUPS to find these two scripts by creating what is
known as a "soft link" from these files to the place where CUPS looks
for such scripts:

ln -s /usr/local/bin/foomatic-rip

ln -s /usr/local/bin/foomatic-gswrapper

If you are reading this where the lines wrap the text around, those
commands may be on two lines each. Just remember they are supposed to be
typed on a single line, and let the Konsole window worry about wrapping.


As mentioned above, FreeBSD is not targeted for the ordinary desktop
user, so some packages do not create everything because they might need
to be in different places depending on how the system is used. We will
need to create some directories CUPS will use for processing its
printing tasks. While installing these packages, you may have seen a
message telling you to run these commands:

cd /var/spool
mkdir -p cups/tmp
chown -R root:daemon cups

Do that now. The command "mkdir" itself makes a new directory. We will
make several more for our desktop configuration:

cd /usr/local/etc/cups/
mkdir certs
mkdir ppd
cd /var/log
mkdir cups

That last one is critically important, as the system will not even be
able to tell you what's wrong if you don't have a place to put error
logs. If you have trouble, the first place to look is
/var/log/cups/error_log to get a clue to what isn't working right.

Now we need to make sure that the printer commands that are not a part
of CUPS can't be used. Navigate to /usr/local/bin/ and rename four files
so that they won't be called by accident:

mv /usr/bin/lp /usr/bin/lp.bak
mv /usr/bin/lpr /usr/bin/lpr.bak
mv /usr/bin/lprm /usr/bin/lprm.bak
mv /usr/bin/lpq /usr/bin/lpq.bak

The "mv" command (move) also renames files. Finally, go to
/usr/local/etc/rc.d/ and find there a file named "cups.sh.sample" and
rename ("move") it to "cups.sh"

mv cups.sh.sample cups.sh

Now you can start the daemon for cups. If it's not running, you can't
set it up with your printer:

./cups.sh start

If you are working from your user account in KDE, and you have used
"su" to access your root account in a Konsole window -- a good security
practice -- then you can start the KDE Control Center with the command
"kcontrol". Open the "Peripherals" section and select the "Printers"
page. There should be a large window in the top half with a list of
"devices" to which you can send files, just as you would to a printer.
Simply right click in that window and select "Add Printer/Class...".

When the window opens up, first is the welcome page, then comes the
connection page. Most of us will choose the first option for USB
printers, but the last one for printers using the older "parallel port"
connection -- be sure it describes the connection as "/dev/lpt0" for
the parallel port. The next window allows you to choose the specific
connection; simply read carefully and choose the one that best fits
your situation. It's the next window that's tricky. It will tell you to
select a printer driver, but offers nothing most of the time. Simply
click on the little folder icon down near the bottom and navigate to
the place were you moved your downloaded PPD file tailor-made for your
printer from Linux Printing.

After that, everything is just a matter of filling in the blanks with
sensible options, taking the defaults for most things. For the sake of
simplicity, the system name I gave my printer is "lp" -- that's an old
standard for Open Source systems. The last thing is a window that pops
up asking to confirm that you have the authority to make system changes,
so type in "root" and root's password and that should be it.

Now, test the setup by going to the last tab in the bottom half of the
Control Center page, marked "Instances" -- be sure the printer is
selected in the top window so that it should say "Default" with a
printer icon in the bottom window. Click the "Test" button on the right
hand side. Make sure the printer is turned on, then confirm sending the
test page to the printer.

If, after a few seconds, you do not see a printer icon in the KDE
Systray, and the printer does not begin to work on the test page, you
need to visit /var/log/cups/error_log and scroll to the bottom to see
what isn't working. Take a look at the time in the left-hand column to
see that it matches roughly when you sent the test page. If it says
nothing, there may be complications with the particular connection in
your /dev folder. There are so many different possibilities it would be
hard to explain the whole process here. This is the time you cultivate
a relationship with a help forum and ask questions. If there is
something in the error log you believe is meaningful but not to you,
include that message in your question. A good resource is:


where you can join at newbies mailing list at the bottom of the page.

When I went through all this, I ran into one last problem: my modem
quit working. Having just enough experience to know that when something
connects for the first time through the files in the /dev folder it can
corrupt other files there, I simply went and re-created my modem
connection. Since my modem is an external serial-port model on the
first serial port, I typed:

./MAKEDEV cuaa0

This fixed the problem.


To learn more about Unix from the newbie perspective, visit the page:


and investigate the links there.

November 25th, 2003, 18:28
Thanks to bumbler for posting all the install guides (especially this one on printing :wink: ). Also thanks to the other SEs who posted info and links on printing recently--everyone's assistance is much appreciated. Alas, too much "real world work" on this end to really sort out the printing during this past week, but it is looking like the ghostfilter needs some tweaking). And, as Turkey Day is approaching, I plan to give the printing another whack on the long weekend. Will post something with specifics, if/when I get that HP6P tamed..............indexer

December 20th, 2003, 01:28
Recent changes at the Linux Printing site have produced printer drivers that won't work properly with CUPS and at least two different kinds of printers: Epson inkjets and some HP inkjets. That's for CUPS on FreeBSD 4.9. For now, the info is deeply suspect for this tutorial. Until someone smarter than me (most BSD users, heh) can figure out what's wrong, I need to sort of suspend this one.

I'm using Apsfilter,which never fails in the first place, for me.