Setting up and maintaining a print service is a major task of a system administrator. In some large organizations a full time printing administrator plans, configures, monitors, maintains, and troubleshoots the printing service, not to mention adding paper and toner when needed. For background information on printing services see How Printing Works. In this project you will set up your server to use the Windows networked printer located in the classroom as your server's default printer.
You will configure the CUPS print system on your
The default print system for some (older) Unix/Linux systems is
not CUPS (common Unix print system).
However, CUPS is the default on more modern Linux and
Unix systems so that is the system you need to know.
A good source for documentation is
In order to configure CUPS you will need to make sure
LPRng print system daemon
is configured not to start automatically in any
In addition the various print system commands (such as
have two versions,
The commands such as
lpr are really
symlinks on Fedora, to one set of commands
or the other.
By default on your system the links may refer to the
set of commands rather than the CUPS versions.
If so this must be changed so that the various user and administrator
commands refer to the CUPS versions.
Finally the CUPS print server
must be set to start automatically
in the standard run-levels, and must be manually turned on now
(if not already running) in order to configure any printers.
To complete your printer setup you will need to gather information about the actual printer to be used, and any networking configuration information.
Printing should work using either the
lpr command, a
Printer icon on the desktop, or a
choice from some GUI application.
The default printer name historically (that is, for
lp and lpr systems) is
, so you can name
your printer that.
However you can have several names (aliases) for each
printer, by modifying the printer configuration file
/etc/printcap for LPR,
/etc/cups/* for CUPS) directly.
(The current version of CUPS doesn't allow this
functionality from the GUI tool yet, but there are
command line tools you can use, or other GUI
In CUPS, printer names are not case-sensitive,
and can contain any characters except white-space.
Beside the GUI interface (and the Red Hat
the CUPS print system can be configured through
a number of command line utilities.
Printers, classes, and servers can be managed with
(Note the older LPRng command
lpc doesn't do much with
CUPS, but is provided with limited functionality.)
System default options for printers can be set using
Note that regular users can also use
to set their own options that over-ride the system defaults.
Finally printing can be configured by directly editing the
/etc/printcap (the configured
printers database) and the CUPS configuration files
It is not recommended to edit these files directly, especially
/etc/printcap, as these files are re-written when the
various administration utilities are used.
This project can only be completed at HCC. Although some time may be provided in class to work on this project, it is likely you will need to schedule extra time outside of class to come to HCC and complete the printing setup. (Do not try to print anything when the class is working on something else!)
Many print servers use TCP, so your default firewall setup will work fine for that (allowing any outgoing TCP connection, and allowing the replies for open connections.)
A Windows print service may rely on some UDP services too, so to communicate with a Windows print server you may need to open additional firewall holes. (You don't need to do this for our classroom setup, but you should understand how.)
To talk SMB (or CIFS) to a
Windows print server you may need to open firewall
holes for ports
TCP/445, and possibly
ports UDP/137, UDP/138, and
This can be done by running the
(which will open a hole until the next reboot):
iptables -I RH-Firewall-1-INPUT -p tcp -m tcp --dport 445 -j ACCEPT
Or by editing the iptables configuration file.
On Fedora/Red Hat systems that is the file
Add the following near the middle somewhere to make a hole:
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 445 -j ACCEPT
Repeat if needed for the other three ports (137–139), used for older Windows servers. To view the current list of iptables rules:
iptables -L -v --line-numbers
It might be easier just to turn off iptables temporarily when testing out your printer setup:
Using the standard CUPS GUI administration tool, the information in your textbook, and the configuration information provided below, create a default printer setup for your computer that will print to the HP laser printer in our classroom.
That printer is attached to a Windows server.
You could therefore use the
(also known as CIFS) to connect to the
In order to connect to the Windows server and use the printer,
you would need to provide your HCC network username
However this printer is networked, so we will bypass the Windows
server and send print jobs to the printer directly.
Nonetheless, you will do some of the steps needed to setup for
a Windows-attached printer, for the learning experience.
Answer all of the following questions, and perform the following tasks:
. Is either
lpdrunning now? If
lpdis running you must stop it. (Note that Fedora 10 and newer uses CUPS and not lprNG.) Exactly what command did you use to stop this service?
lpdand CUPS services configured to start automatically? Use the
chkconfigcommand to find out; if using
systemd, find the
cups.servicefile and look in the “
[Install]” section for the value of the “
chkconfigto do this. In which run-levels is CUPS now configured to start?
/usr/bin/lprand others are actually symlinks (or symbolic links or soft links). The reason is that there are often two versions of these commands, one set for the
LPRngprint system and one for the CUPS print system. To facilitate the switching from one system to another Red Hat (including Fedora) has adopted the
alternativessystem. For example the
lprsymlink points to another symlink,
/etc/alternatives/print, which in turn points to either
/usr/bin/lpr.cups. What is the ultimate command (e.g., non-symlink) executed on your system now for the
LPRngto CUPS. To switch all the printing related symlinks at once you should use the
alternatives --config printcommand. Here's a sample session:
[root@YborStudent root]# cd /etc/alternatives [root@YborStudent alternatives]# ls -l print lrwxrwxrwx 1 root root 17 Apr 10 2003 print -> /usr/bin/lpr.LPRng [root@YborStudent alternatives]# alternatives --config print There are 2 programs which provide 'print'. Selection Command ----------------------------------------------- 1 /usr/bin/lpr.cups *+ 2 /usr/bin/lpr.LPRng Enter to keep the default[*], or type selection number: 1 [root@YborStudent alternatives]# ls -l print lrwxrwxrwx 1 root root 17 Nov 6 19:09 print -> /usr/bin/lpr.cups [root@YborStudent alternatives]#
/dev/lp0), or by forwarding the print job to another print server that manages the printer (this may be a Windows/SMB/CIFS print service, a CUPS service, or something else).
In some cases the printer contains its own internal printer server;
this is called a networked printer.
Many Hewlett-Packard (
HP) models contain a print
server known as a
Jet Direct card.
CUPS can control local printers and talk to remote print servers to
forward print jobs, but it will need the correct driver to talk
to that printer.
CUPS calls these drivers
You need to determine how your host will communicate to the printer
or remote print server, and make certain the correct back-end is
Fortunately for you the current version of CUPS pre-installs many commonly used back-ends for you. However you still need to know which back-end to use.
In order for CUPS to be able to use Samba's SMB to
communicate with Windows servers, you must verify the
smb backend for CUPS is
Run the command
Which backends is your version of CUPS
configured to use?
smb is not listed you must add it
by running the following commands:
which smbspool # This command verifies you have samba installed on # your system. If this doesn't locate the file you # must install the samba packages before proceeding. ln -s `which smbspool` /usr/lib/cups/backend/smb
again. Is CUPS running? (Look for the actual command of
cupsd.) Examine the system log with the command
. What messages (if any) appear related to printing?
tail -50 /var/log/messages
Previously this printer was managed by a Windows print server
In January 2007 the printer in DTEC-461 was moved
to a new subnet (i.e., network LAN).
While in theory it is still possible to connect via Samba
dmtec2 Windows print server,
in practice the firewall between
dmtec2 and our
classroom LAN makes such access difficult from our
Fortunately it is possible to connect directly to the printer,
so that's what you will do for this project.
But how to connect? It would depend on the type of print server installed in that printer (if any) and it's configuration. It is useful to know how to figure out this sort of information, as this type of situation occurs more frequently than you might suspect.
A physical examination of this printer should tell you:
, so this printer supports PCL. (A PostScript printer would be your default guess, especially if the LCD display shows
PS. Even if nothing showed you can guess PostScript first and if that doesn't work try PCL next.)
Configurationpage (which will include the printer's IP address). At the product control panel, press
Menu, Then press the down-arrow to highlight
INFORMATIONand then press
OK. Press the down-arrow to highlight
PRINT CONFIGURATIONand then press
portsare accepting connections. The
port numbersof open ports will indicate which types of print servers (if any) are available on this printer.
After making sure the printer is powered on, run
(You may have to install
nmap Printer's IP
An easy way would be
What port(s) are open on the printer?
yum install nmap
grepfor the port numbers on the file
/etc/services. You can also Google for information with a query similar to
port number 12345. What type of print servers are available (if any) on this printer?
Now configure the printer and print a test page, using the following steps. (See the Troubleshooting Hints below if you have a problem.)
Helpbutton for on-line documentation.)
tab to view the screen that shows your configured printers. This should show
No printersfor now.
Administrationtab, then click the
Add Printerbutton to begin a wizard to add a printer. Note you will need to provide the
rootpassword for your system to configure printing.
Devicefor your printer: a serial port, a parallel (printer) port, an
LPRnetworked connection, a USB port, etc. You can select only the devices for which you have a backend installed. Scroll through the list that appears and you should see a choice for the type of print server controlling the printer. (If it doesn't appear on your system, make sure networking is up and running!) enter the device for the protocol you decided to use (from among the ones supported by the printer).
smb://username:password@domain/server/sharewhere the username and password are your valid HCC network user ID and password. The remaining parts of the URI can be found in the table provided below. For a JetDirect print server at IP address
184.108.40.206the correct back-end is called
AppSocket/HP JetDirect, and the correct URI is
. What URI did you use?
If you try to use a printer unsupported with the current version of
CUPS, you can find an different installation of CUPS you may be able
to copy the PPD file needed.
(You can try to find a free one on the Internet using Google;
maybe you'll have more luck than I did!)
If no exact matching PPD file is available you need
to use the nearest match.
Which PPD files (print drivers)
show on the list that you would consider as possible
PPDs to use for
a LaserJet III Si printer?
(Don't forget to consider the non-HP
PPD files available, such as one for any
PostScript 3 printer or for any
PCL 6 printer.)
Of course the real answer is not to use a 15+ year old printer,
or to pay for the correct PPD,
or to write (or hire a consultant to write)
a custom PPD.
If no models listed seem a reasonable choice, choose a generic
Maintenancedrop-down list of commands that shows on the printer page. (Make sure no one else is using the printer when you try this!) If this fails to work, modify the printer by choosing a different PPD file. Which PPD file did you ultimately use? (Please recycle any extra used paper!)
lprcommand to print a copy of your system's
/etc/passwdfile. You can use the
prcommand to format the printing of the
/etc/passwdfile, including a page header with the date and your name in it. You can either pipe the output of
lpr, or use special
lproptions to set a header. See the
prman pages for details. What error message(s) did you get when you tried this?
lpoptionscommand. What was the exact command used to set your default printer? In what file is that option recorded?
lpoptions(changes made using this command as root don't set the root user's defaults but the system-wide defaults), go back to the CUPS web page, select your printer from the
Printerstab, and make it the default using the
Administrationdrop-down list of commands. What file gets modified when you set system-wide CUPS defaults this way? Verify the default works by printing something. (As before, make sure no one else is printing when you try this, and remember to recycle and not discard used paper.)
The last step is to determine a maintenance schedule, and to order the correct supplies (replacement parts for the printer elements that wear out after a certain number of pages have been printed, toner, cleaning supplies, etc.) in a timely fashion.
After trying to locate the information you may come to the Hewlett-Packard support site for this printer. You should be able to find manuals describing the use and setup of the printer, and maintenance information.
A printout of the CUPS test page that you produced,
a printout of your
/etc/passwd file, and a
printout of your system journal entries describing
in detail the printing setup on your system
and the answers to the questions above.
Make sure your name is clearly printed at the top of each page and
remember to staple all the pages together.
You can submit project questions to . Please see your syllabus for more information about submitting projects.
Make sure no one else is printing a test page at the same time you are, since there is no way to tell whose setup worked and whose didn't when only one page prints!
If you ever need to use the SMB protocol to print
to a Windows print server (and you won't for this project),
you will not need to start the
Samba server is used to make your Linux system
appear in the Network Neighborhood of other computers,
as if it were another Windows server.
You don't need the server on the local system to be running to use
SMB or the
Samba client tools to print to a Windows
(You only would need this if you wanted to offer print services to
Be careful when entering in the information, it is easy to make a
typo when entering the URIs.
One common problem is using the wrong type of slash (use
forward slashes (
/) not backslashes).
Some problems that can occur if using SMB include
using a Windows account that was never activated (or that
has been deactivated), using the wrong Windows password, using a
Windows password that contains special characters (shell
metacharacters such as
*, ?, \, !, $, ', ",
a space, etc.), and using a password that is too long.
To print to an HCC Windows printer you will need a valid HCC Windows network username and password. You can learn your HCC network ID by using WebAdvisor. Even if you are certain your HCC network ID and password are fine, you should walk to the open lab and attempt to log in using that username and password on one of the Windows computers. If you have any problems with your HCC ID, consult with a lab tech.
A Windows Share name is the unique UNC
(Universal Naming Convention) name of a shared resource
such as a printer, in the form
//server_name/printer_name or (as in our case)
If the correct printer driver is selected the resulting printout
should appear fine for either text or PostScript.
However your version of CUPS may not ship with the
exact printer driver for some printer models.
To fix this you can upgrade the printing packages on your system
which will (hopefully) include the correct printer driver.
If you can't find the one you need, experiment a bit with printer
drivers for similar printers.
You will usually find one that works pretty well.
If all else fails you can use the generic
If the first driver you select doesn't work and you go to change it,
Using the standard CUPS GUI tool you must go through
the wizard again.
All the old information is preserved so all you need to is to
continue at each step, until you come to the driver
choice (where you will make a new selection).
However, for security reasons the
username and password don't appear in the displayed
I've learned that if you just click continue to get to the
driver selection page, the information that is showing replaces
the information that was stored.
In short, the username and password will vanish if you just
continue on that page!
The fix is easy, just re-enter your username and password into
the URI that shows.
If all else fails, after attempting to print a test page
check the log files for errors, especially
In the table below is the specific information needed to configure a printer on Linux for remote printing to the printer in room 461. This printer is attached to a Windows server. To use the Windows print server, you would need to use Samba and your HCC network user ID and password to use this printer via the Windows print server. However it is not necessary to use that Windows print server; you can print directly to the printer. But if multiple hosts print to the printer at the same time, it is difficult to know who printed what.
Most of the information used is case-sensitive, so be sure to enter it exactly as shown. Some of the data in the table (shown in gray) would only be needed to connect to a Windows print server, and is for informational use only.
|Domain (Workgroup) Name|
|Note: if you don't see this exact model listed, try to find the closest match possible. You may have to try more than one if the first doesn't work.|