# Chapter 10. Printing

This chapter tackles the topic of setting up printers for use with Samba. Aside from the "coolness factor" of seeing documents from Windows word processing and graphics applications appearing in the output tray of the Unix printer, this facility can greatly increase the usefulness of your Samba server. In many organizations, using a Unix system as the print server has led to happier system administrators and users alike, due to the reduced frequency of problems.

Samba allows client machines to share printers connected to the Samba host system, and Samba can also send Unix documents to printers shared by Windows systems. In this chapter, we discuss how to get printers configured to work in either direction.

We focus in this chapter on getting Samba to serve up printers that are already functioning on the Unix host. We include just a few basics about setting up printers on Unix. Good references for this topic include Network Printing, Essential System Administration, and Running Linux, all by O'Reilly and Associates.

## Sending Print Jobs to Samba

A printer shared by the Samba server shows up in the list of shares offered in the Network Neighborhood. If the printer is registered on the client machine and the client has the correct printer driver installed, the client can effortlessly send print jobs to a printer attached to a Samba server. Figure 10-1 shows a Samba printer as it appears in the Network Neighborhood of a Windows client.

#### Figure 10-1. A Samba printer in the Network Neighborhood

To administer printers with Samba, you should understand the basic process by which printing takes place on a network. On the client system, the application software prints by utilizing the system's printer driver for the printer that will be creating the actual output. It is the printer driver software running on the client system that translates the application's high-level calls into a stream of binary data specific to the model of printer in use. In the case of a serial, parallel, or USB printer, the data is stored in a temporary file in the local system's printer queue and then sent through the respective port directly to the printer. For a network printer, the file is sent over the network.

> #### TIP

> Because the data has already been processed through a printer driver by the time it reaches the Samba host, make sure the printer on the Unix system is configured without any printer driver and that it will print whatever data it receives in raw form. If you already have the printer configured for use by Unix applications, you might need to set up another queue for it to print documents received from Windows clients correctly.

Sending a print job to a printer on a Samba server involves four steps:

1. Opening and authenticating a connection to the printer share

2. Copying the file over the network

3. Closing the connection

4. Printing and deleting the copy of the file

When a print job arrives at a Samba server, the print data is temporarily written to disk in the directory specified by the `path` option of the printer share. Samba then executes a Unix print command to send that datafile to the printer. The job is then printed as the authenticated user of the share. Note that this can be the guest user, depending on how the share is configured.

### Print Commands

To print the document, you'll need to inform Samba of the command used to print and delete a file. On Linux, which uses a BSD-style printing system, a command that does this is:

>     lpr -r -Pprinter file

This command tells lpr to retrieve the name of the printer in the system configuration file (/etc/printcap) and interpret the rules it finds there to decide how to process the data and which physical device to send it to. Note that because the -r option has been specified, the file will be deleted after it has been printed. Of course, the file removed is just a copy stored on the Samba server; the original document on the client is unaffected.

The process is similar on System V Unix. Here, printing and deleting become a compound command:

>     lp -dprinter -s file; rm file

In this case, the /etc/printcap file is replaced with a different set of configuration files residing in /usr/spool/lp. Because the lp command has no option to delete the file after it is printed, we have added the rm command.

### A Minimal Printing Setup

Let's start with a simple yet illustrative printing share. Assuming that you're on a Linux system and you have a printer called `netprinter` listed in the printer capabilities file, the following addition to your smb.conf file makes the printer accessible through the network:

>     [printer1]
>         printable = yes
>         print command = /usr/bin/lpr -P%p -r %s
>         printer = netprinter
>         printing = BSD
>         path = /var/tmp

The variable `%s` in the `print` `command` option is replaced with the name of the file to be printed when Samba executes the command. There are four Samba configuration-file variables specifically for use with printing options. They are shown in Table 10-1.

#### Table 10-1. Printing variables

Variable | Definition
--- | ---
`%s` | The full pathname of the file on the Samba server to be printed
`%f` | The name of the file itself (without the preceding path) on the Samba server to be printed
`%p` | The name of the Unix printer to use
`%j` | The number of the print job (for use with `lprm`, `lppause`, and `lpresume`)

For other flavors of Unix, it is necessary to modify both the `printing` and `print` `command` options. For System V Unix, we would specify:

>     [printer1]
>         printing = SYSV
>         print command = lp -d%p -s %s; rm %s

With the `printing` `=` `SYSV` parameter, we notify Samba that the local printing system uses the System V Unix method. As mentioned earlier, the `%p` variable resolves to the name of the printer, while the `%s` variable resolves to the name of the file.

Clients might need to request the status of a print job sent to the Samba server. Because Samba sends print jobs to the Unix printing system for spooling, there might be a number of jobs in the queue at any given time. Consequently, Samba needs to communicate to the client not only the status of the current printing job, but also which documents are waiting to be printed on that printer. Samba also has to provide the client the ability to pause print jobs, resume print jobs, and remove print jobs from the printing queue. Samba provides options for each of these tasks. As you might expect, they borrow functionality from the following existing Unix commands:

- `lpq`

- `lprm`

- `lppause`

- `lpresume`

We cover these options in more detail later in this chapter. For the most part, Samba provides reasonable default values for them based on the value of the `printing` configuration option, so you can probably get by without having to formulate your own commands for them.

Here are a few important items to remember about printing shares:

- You must put `printable` `=` `yes` in all printer shares (even `[printers]`) so that Samba knows they are printer shares. If you forget, the shares will be unusable for printing and will instead be treated as disk shares.

- If you set the `path` configuration option in the printer section, any files sent to the printer(s) will be copied to the directory you specify instead of to the default location of /tmp. Because the amount of disk space allocated to /tmp can be relatively small in some Unix operating systems, many administrators prefer to use /var/tmp, /var/spool/tmp, or some other directory instead.

- If you set `guest` `ok` `=` `yes` in a printer share and Samba is configured for share-level security, anyone can send data to the printer as the `guest` `account` user.

Using one or more Samba machines as a print server gives you a great deal of flexibility on your LAN. You can easily partition your available printers, restricting some to members of one department, or you can maintain a bank of printers available to all. In addition, you can restrict a printer to a select few by adding the `valid` `users` option to its share definition:

>     [deskjet]
>         printable = yes
>         path = /var/spool/samba/print
>         valid users = elizabeth cozy jack heather alexander lina emerald

All the other share accessibility options work for printing shares as well.

### The [printers] Share

If a share named `[printers]` is in the configuration file, Samba will automatically read in your printer capabilities file and create a printing share for each printer that appears in the file. For example, if the Samba server had `lp`, `pcl`, and `ps` printers in its printer capabilities file, Samba would provide three printer shares with those names, each configured with the options in the `[printers]` share.

Recall that Samba obeys the following rules when a client requests a share that has not been created with an explicit share definition in the smb.conf file:

- If the share name matches a username in the system password file and a `[homes]` share exists, a new share is created with the name of the user and is initialized using the values given in the `[homes]` and `[global]` sections.

- Otherwise, if the name matches a printer in the system printer capabilities file and a `[printers]` share exists, a new share is created with the name of the printer and initialized using the values given in the `[printers]` section. (Variables in the `[global]` section do not apply here.)

- If neither of those succeeds, Samba looks for a `default` `service` share. If none is found, it returns an error.

This brings to light an important point: be careful that you do not give a printer the same name as a user. Otherwise, users end up connecting to a disk share when they might have wanted a printer share instead.

Here is an example `[printers]` share for a Linux system. Some of these options are already defaults; however, we have listed them anyway for illustrative purposes:

>     [printers]
>         printable = yes
>         printing = BSD
>         printcap name = /etc/printcap
>         print command = /usr/bin/lpr -P%p -r %s
>         path = /var/spool/lpd/tmp
>         min print space = 2000

Here, we've given Samba global options that specify the printing type (BSD), a print command to send data to the printer and later remove the temporary file, the location of our printer capabilities file, and a minimum disk space for printing of 2MB.

In addition, we've created a `[printers]` share for each system printer. Our temporary spooling directory is specified by the `path` option: /var/spool/lpd/tmp. Each share is marked as printable—this is a necessary option, even in the `[printers]` section.

### Testing the Configuration

After running testparm and restarting the Samba daemons, you can check to make sure everything is set up correctly by using smbclient to send a file to the printer. Connect to the printer using the command:

>     # smbclient /server/printshare

and then use the print command to print a file:

>     smb: /> print textfile

> #### TIP

> If you connect to a print share served by a Windows 95/98/Me system configured to use user-mode security and cannot authenticate using what you know to be a correct username and password, try reconfiguring the Windows system to use share-mode security.

When you print something through the Samba server via smbclient, the following actions should occur:

- The job appears (briefly) in the Samba spool directory specified by the path.

- The job shows up in your print system's spool directory.

- The job disappears from the spool directory that Samba used.

If smbclient cannot print, you can reset the `print` `command` option to collect debugging information:

>     print command = echo "printed %s on %p" >>/tmp/printlog

A common problem with Samba printer configuration is forgetting to use the full pathnames for commands. Another frequent problem is not having the correct permissions on the spooling directory.[1] As usual, check your Samba log files and system log files for error messages. If you use BSD printing, you can change the `lp` keyword in the printer's printcap entry to something other than /dev/null, allowing you to collect error messages from the printing system.

> #### TIP

> More information on debugging printers is in the file docs/textdocs/Printing.txt in the Samba source distribution. The Unix print systems are covered in detail in Æleen Frisch's Essential Systems Administration (published by O'Reilly).

### Enabling SMB Printer Sharing in Mac OS X

With Samba preinstalled with Mac OS X, sharing access to a printer among Windows clients is easy. First, of course, you should set up local access using the Print Center application (located in /Applications/Utilities). Under the Printers menu, select Add Printer..., and make the appropriate selection from the pop-up menu. For example, if the printer is directly attached, select USB; if the printer is powered on, it should appear in the list. Choose the printer, and press the Add button.

Edit /etc/smb.conf, uncommenting the `[printers]` share and making any additional configuration changes you feel are necessary. Finally, enable the Samba startup item as described in Chapter 2, either by checking Windows File Sharing in Sharing Preferences or by manually editing /etc/hostconfig. Now your printer can be used by remote Windows clients.

On Mac OS X and some other BSD-based systems, you can test your configuration using smbutil. The following will send the file named print_test_file to the printer named printshare on the server bsdserver :

>     % smbutil print //bsdserver/printshare print_test_file

See Chapter 5 for more information on using smbutil.

### Setting Up and Testing a Windows Client

Now that Samba is offering a workable printer, you can set up your access to it on a Windows client. Browse through the Samba server in the Network Neighborhood. It should now show each printer that is available. For example, in Figure 10-1, we saw a printer called `lp`.

Next, you need to have the Windows client recognize the printer. Double-click the printer icon to get started. If you try to select an uninstalled printer (as you just did), Windows will ask you if it should help configure it for the Windows system. Click the Yes or OK button, and the Printer Wizard will open.

If you are installing a printer on Windows 95/98/Me, the first thing the wizard will ask is whether you need to print from DOS. Let's assume you don't, so choose the "No" radio button and press the Next > button to get to the manufacturer/model window, as shown in Figure 10-2.

#### Figure 10-2. Setting the manufacturer and model of the printer

In this dialog box, you should see a large list of manufacturers and models for a huge number of printers. Select the manufacturer of your printer in the left side of the dialog box, and then the exact model of the printer in the list on the right side.

In some cases, you might not find your printer in the list, or the version of the printer driver included with Windows might be out of date. In cases such as these, consult the printer manufacturer's documentation on how to install the driver. Typically, you will click the Have Disk... button to install the driver from a CD-ROM or disk file.

If you don't see your printer on the list, but you know it's a PostScript printer, select Apple as the manufacturer and Apple LaserWriter as the model. This will give you the most basic PostScript printer setup—and arguably one of the most reliable. If you already have PostScript printers attached, you will be asked about replacing or reusing the existing driver. Be aware that if you replace it with a new one, you might make your other printers fail. Therefore, we recommend you keep using your existing printer drivers as long as they're working properly.

Click the Next > or OK button. On Windows 95/98/Me, the Printer Wizard asks you to name the printer. On Windows NT/2000/XP, you need to right-click the printer's icon and select Properties to assign the printer a name. Figure 10-3 shows how we've named our printer to show that it's shared by the `mixtec` Samba server.

#### Figure 10-3. Setting the printer name

Finally, on Windows 95/98/Me the Printing Wizard asks if it should print a test page. Click the "Yes" radio button, then the Finish button, and you should be presented with the dialog box shown in Figure 10-4. On Windows NT/2000/XP, the printer test function is also accessed through the printer's Properties dialog box.

#### Figure 10-4. Sending a test page to the printer

If the test printing was unsuccessful, click the No button and the Printing Wizard will walk you through some debugging steps for the client side of the process. If the test printing does work, the remote printer will now be available to all Windows applications through the File and Print menu items.

## Printing to Windows Printers

If you have printers connected to systems running Windows 95/98/Me or Windows NT/2000/XP, the printers can also be accessed from your Unix system using tools that are part of the Samba distribution. First, it is necessary to create a printer share on the Windows system. Then set up the printer on the Unix side by configuring a new printer and using a Samba printing program as the printer's filter.

### Sharing Windows Printers

Sharing printers on Windows is not unlike sharing files. In fact, it is a little simpler. Open the Control Panel, then double-click the Printers icon to open the Printers window. Right-click the icon for the printer you want to share, and select Sharing.... This opens the dialog box shown in Figure 10-5 for a Windows 98 system, or Figure 10-6 on a Windows 2000 system. (The dialog box appears slightly different on other Windows versions, but functions almost identically.)

> #### TIP

> On Windows 95/98/Me systems, you may need to run file sharing in share-level (rather than user-level) access control mode to access a shared printer from Samba. To check or set this mode, go to Control Panel, then double-click on Network, then click on the Access Control tab. More detailed information on this can be found in Chapter 5.

#### Figure 10-5. Sharing printers on Windows 98

#### Figure 10-6. Sharing printers on Windows 2000

Click the "Shared as" radio button, then click the OK button. The printer is now accessible by other systems on the network.

### Adding a Unix Printer

The Samba distribution comes with three programs that assist with printing on shared printers. The smbprint program works with systems that use the BSD printing system, smbprint.sysv works with systems that use System V printing, and smbspool works with systems that use the Common Unix Printing System (CUPS). In the following sections we show you how to install printers for each system.

### BSD printers

The BSD printing system is used by many Unix variants, including Red Hat Linux. With BSD printing, all the printers on the system have an entry in the /etc/printcap file, which is the database of printer capabilities used by the lpd line printer daemon and other programs that assist with printing. The Red Hat Linux implementation is a bit different in that /etc/printcap is a machine-generated file, which is re-created every time the lpd daemon is restarted by the /etc/rc.d/init.d/lpd script. Instead of editing /etc/printcap, we will add an entry for our printer in /etc/printcap.local, which the system automatically includes verbatim when creating /etc/printcap.

> #### TIP

> If you are using the version of Samba installed from an RPM file as on Red Hat Linux, you might be able to skip these directions and use the printconf tool, which has support for SMB printers. Unfortunately, this tool might not work correctly if you have installed Samba from the Samba source distribution.

Here is the entry we added to our /etc/printcap.local file to support our Hewlett-Packard DeskJet 932C printer, which is shared by `maya`, a Windows 98 system:

>     lp|maya-hp932c:\
>         :cm=HP 932C on maya:\
>         :sd=/var/spool/lpd/maya:\
>         :af=/var/spool/lpd/maya/acct:\
>         :if=/usr/local/samba/bin/smbprint:\
>         :mx=0:\
>         :lp=/dev/null:

The first line creates names for the printer. We are calling it both `maya-hp932c`, to describe its location on the network and the type of printer, and `lp` so that programs will use it as the default printer. The rest of the lines specify keywords and values. The `cm` keyword allows us to assign a comment string to the printer. The `sd` and `af` keywords assign the printer's spool directory and accounting files, respectively. The `if` keyword assigns the print filter. We are using the smbprint command to send the output to the shared SMB printer. The `mx` keyword is set to zero to allow any size file to be printed, and `lp` is set to /dev/null to discard error messages.

You can follow our model to create an entry for your own printer. If you want to go beyond the capabilities we used, refer to your system's printcap(5) manual page for a complete listing of keywords.

Go to your Samba source distribution's root directory, and install the smbprint program like this:

>     # cp examples/printing/smbprint /usr/local/samba/bin

We next create the printer's spool directory:

>     # cd /var/spool/lpd
>     # mkdir maya
>     # chown lp:lp maya
>     # chmod 700 maya

The smbprint program looks for a file named .config in the printer's spool directory, which contains information on how to connect to the printer share. We create this file and then fill in the required information:

>     # cd maya
>     # >.config
>     # chown lp:lp .config
>     # chmod 600 .config

Use your preferred text editor to edit the .config file, and enter three lines, like this:

>     server=maya
>     service=hp
>     password=""

This is for our shared printer having a UNC of \\maya\hp. When we created the printer share, we did not give it a password, so we use a null password here. If your printer share is on a Windows NT/2000/XP system, use your domain password.

Finally, restart the printer daemon:

>     # /etc/rc.d/init.d/lpd restart

You can now try printing something. Run the following command:

>     $ lpr textfile

If you have everything set up correctly, the file prints on the shared printer. If you get "stair stepping" of text, caused by the printer not returning to the left margin at the beginning of every line, modify the `if` keyword in your printcap entry to run smbprint with the -t option.

### System V printers

Sending print jobs from a System V Unix system is a little easier than with the BSD system. Here, you need to edit the smbprint.sysv script in the examples/printing directory of the Samba distribution and do the following:

1. Change the `server`, `service`, and `password` parameters in the script to match the NetBIOS computer name, its shared printer service, and its password, respectively. For example, the following entries would be correct for the service in the previous example:

   >     server = maya
   >     service = hp
   >     password = ""

2. Run the following commands, which create a reference for the new printer (which we are naming `hp_printer`) in the printer capabilities file:

   >     # lpadmin -p hp_printer -v /dev/null -i./smbprint.sysv
   >     # enable hp_printer
   >     # accept hp_printer

After you've done that, restart the Samba daemons and try printing to `hp_printer` using any standard Unix program.

### CUPS printers

CUPS[2] uses a set of modules, called backends, to send print jobs to various destinations, such as local printers attached to parallel, serial, or Universal Serial Bus (USB) ports, or over the network using Unix line printer daemon (LPD) protocol, Internet Printing Protocol (IPP), AppleTalk Printer Access Protocol (PAP), and so on. The software package does not come with a backend for SMB; the Samba suite includes the smbspool utility for this purpose.

To enable printing to remote SMB printers using CUPS, create a symbolic link named smb in the CUPS backend directory pointing to smbspool. Depending on installation options, these could be in a number of places in the directory hierarchy, so be sure to check your system. Using a common default installation, the command would look like this:

>     # ln -s /usr/local/samba/bin/smbspool /usr/lib/cups/backend/smb

Issue a HUP signal to the CUPS daemon, cupsd, and check for the existence of SMB support with the lpinfo -v command. Its output should now include a line that says `network` `smb`.

To add a printer, use the CUPS web interface, accessible on the local system at http://localhost:631/, or use the lpadmin command:

>     # lpadmin -p hp932c -E -v smb://maya/hp932c -D "HP 932C on maya"

This creates and enables the new print spool called `hp932c`. The -v argument specifies the printer device, which in this case is accessed over the network using an SMB URI. If the printer is not guest-accessible, you'll need to provide a username and password in the URI. The full format is as follows:

>     smb://[username[:password]@][workgroup/]server/printshare

The lpadmin command makes changes to /etc/cups/printers.conf and sends a HUP signal to the cupsd daemon, resulting in the creation of a local raw printer spool. In this example, print data is passed in raw format to the Windows system, which has the necessary printer drivers and printer description files to format the data appropriately. The -D option is used to give the printer a comment string.

Once you have the printer set up, it's time to test it out. CUPS understands both BSD-style and System V-style printing commands, so you can use whichever is more comfortable. Using the BSD lpr command, try something like:

>     $ lpr -P hp932c textfile

You should now be set up to use the printer from any application on the Unix system.

### Samba Printing Options

Table 10-2 summarizes the Samba printing options.

#### Table 10-2. Printing configuration options

Option | Parameters | Function | Default | Scope
--- | --- | --- | --- | ---
`printing` | `bsd`, `sysv`, `cups`, `hpux`, `aix`, `qnx`, `plp`, `softq`, or `lprng` | Printing system type of the Samba host | System-dependent | Share
`printable` `(print ok)` | boolean | Marks a share as a printing share | `no` | Share
`printer` `(printer name)` | string (Unix printer name) | Name for the printer that is shown to clients | System-dependent | Share
`lpq cache time` | numeric (time in seconds) | Amount of time in seconds that Samba will cache the printer queue status | `10` | Global
`postscript` | boolean | Treats all print jobs as PostScript by prefixing `%!` at the beginning of each file | `no` | Share
`load printers` | boolean | If `yes`, automatically loads each printer in the printcap file as printing shares | `yes` | Global
`print command` | string (shell command) | Unix command to perform printing | See below | Share
`lpq command` | string (shell command) | Unix command to return the status of the printing queue | See below | Share
`lprm command` | string (shell command) | Unix command to remove a job from the printing queue | See below | Share
`lppause command` | string (shell command) | Unix command to pause a job on the printing queue | See below | Share
`lpresume` `command` | string (shell command) | Unix command to resume a paused job on the printing queue | See below | Share
`printcap name` `(printcap)` | string (filename) | Location of the printer capabilities file | System-dependent | Global
`min print space` | numeric (size in kilobytes) | Minimum amount of free disk space that must be present to print | `0` | Share
`queuepause` `command` | string (shell command) | Unix command to pause a queue | See below | Share
`queueresume` `command` | string (shell command) | Unix command to resume a queue | See below | Share

### printing

The `printing` configuration option tells Samba which printing system to use. There are several different families of commands to control printing and print statusing. Samba supports seven different types, as shown in Table 10-3.

#### Table 10-3. Printing system types

Variable | Definition
--- | ---
BSD | Berkeley Unix system
SYSV | System V
CUPS | Common Unix Printing System
AIX | IBM's AIX operating system
HPUX | Hewlett-Packard Unix
QNX | QNX Realtime Operating System
LPRNG | LPR Next Generation
SOFTQ | SOFTQ system
PLP | Portable Line Printer

The value for this option must be one of these seven selections. For example:

>     printing = SYSV

The default value of this option is system-dependent and is configured when Samba is first compiled. For most systems, the configure script automatically detects the printing system to be used and configures it properly in the Samba makefile. However, if your system is a PLP, LPRNG, or QNX printing system, you need to specify this explicitly in the makefile or the printing share.

The most common system types are BSD, SYSV, and CUPS. Each printer on a BSD Unix server is described in the printer capabilities file—normally /etc/printcap. See the section on the `printcap` `file` parameter for more information on this topic.

Setting the `printing` configuration option automatically sets at least three other printing options for the service in question: `print` `command`, `lpq` `command`, and `lprm` `command`. If you are running Samba on a system that doesn't support any of the printing styles listed in Table 10-3, simply set the commands for each of these manually.

### printable

The `printable` option must be set to `yes` to flag a share as a printing service. If this option is not set, the share will be treated as a disk share instead. You can set the option as follows:

>     [printer1]
>         printable = yes

### printer

The option, also called `printer` `name`, specifies the name of the printer on the server to which the share points. This option has no default and should be set explicitly in the configuration file, even though Unix systems themselves often recognize a default name such as `lp` for a printer. For example:

>     [deskjet]
>         printer = hpdkjet1

### lpq cache time

The global `lpq` `cache` `time` option allows you to set the number of seconds for which Samba will remember the current printer status. After this time elapses, Samba will issue an lpq command (or whatever command you specify with the `lpq` `command` option) to get a more up-to-date status that it can report to users. This defaults to 10 seconds, but can be increased if your `lpq` `command` takes an unusually long time to run or you have lots of clients. A time setting of 0 disables caching of queue status. The following example resets the time to 30 seconds:

>     [deskjet]
>         lpq cache time = 30

### postscript

The `postscript` option forces the printer to treat all data sent to it as PostScript. It does this by prefixing the characters `%!` to the beginning of the first line of each job. It is normally used with PCs that insert a `^D` (control-D or "end-of-file" mark) in front of the first line of a PostScript file. It will not, obviously, turn a non-PostScript printer into a PostScript one. The default value of this options is `no`. You can override it as follows:

>     [deskjet]
>         postscript = yes

### load printers

The `load` `printers` option tells Samba to create shares for all known printer names and load those shares into the browse list. Samba will create and list a printer share for each printer name in /etc/printcap (or the system equivalent). For example, if your printcap file looks like this:[3]

>     lp:\
>       :sd=/var/spool/lpd/lp:\            spool directory
>       :mx#0:\                            maximum file size (none)
>       :sh:\                              supress burst header (no)
>       :lp=/dev/lp1:\                     device name for output
>       :if=/var/spool/lpd/lp/filter:      text filter

>     laser:\
>       :sd=/var/spool/lpd/laser:\         spool directory
>       :mx#0:\                            maximum file size (none)
>       :sh:\                              supress burst header (no)
>       :lp=/dev/laser:\                   device name for output
>       :if=/var/spool/lpd/lp/filter:      text filter

the shares `[lp]` and `[laser]` are automatically created as valid print shares when Samba is started. Both shares borrow the configuration options specified in the `[printers]` section to configure themselves and are available in the browse list for the Samba server. The default value for this option is `yes`. If you prefer to specify each printer explicitly in your configuration file, use the following:

>     [global]
>         load printers = no

### print command, lpq command, lprm command,lppause command, lpresume command

These options tell Samba which Unix commands control and send data to the printer. The Unix commands involved are: lpr (send to Line PRinter), lpq (List Printer Queue), lprm (Line Printer ReMove), and optionally lppause and lpresume. Samba provides an option named after each command, in case you need to override any of the system defaults. For example, consider the following:

>     lpq command = /usr/ucb/lpq %p

This would set `lpq` `command` to use /usr/ucb/lpq. Similarly:

>     lprm command = /usr/local/bin/lprm -P%p %j

would set the Samba printer remove command to /usr/local/bin/lprm and provide it the print job number using the `%j` variable.

The default values for each option are dependent on the value of the `printing` option. Table 10-4 shows the default commands for each printing option. The most popular printing system is BSD.

#### Table 10-4. Default commands for various printing options

Option | BSD, AIX, PLP, LPRNG | SYSV, HPUX | QNX | SOFTQ
--- | --- | --- | --- | ---
`print` `command` | `lpr -r -P%p %s` | `lp -c -d%p %s; rm` `%s` | `lp -r -P%p %s` | `lp -d%p -s %s; rm %s`
`lpq` `command` | `lpq -P%p` | `lpstat -o%p` | `lpq -P%p` | `lpstat -o%p`
`lprm` `command` | `lprm -P%p %j` | `cancel %p-%j` | `cancel %p-%j` | `cancel %p-%j`
`lppause` `command` | `lp -i %p-%j -H` `hold` (SYSV only) | None | None | None
`lpresume` `command` | `lp -i %p-%j -H` `resume` (SYSV only) | None | None | `qstat -s -j%j -r`

It is usually unnecessary to reset these options in Samba, with the possible exception of the `print` `command`. This option might need to be set explicitly if your printing system doesn't have a -r (remove after printing) option on the printing command. For example:

>     print command = /usr/local/lpr -P%p %s; /bin/rm %s

With a bit of judicious programming, these smb.conf options can also be used for debugging:

>     print command = cat %s >>/tmp/printlog; lpr -r -P%p %s

Using the previous configuration, it is possible to verify that files are actually being delivered to the Samba server. If they are, their contents will show up in the file /tmp/printlog.

After BSD, the next most popular kind of printing system is SYSV (or System V) printing, plus some SYSV variants for IBM's AIX and Hewlett-Packard's HP-UX. These systems do not have an /etc/printcap file. Instead, the `printcap` `file` option can be set to an appropriate lpstat command for the system. This tells Samba to get a list of printers from the lpstat command. Alternatively, you can set the global configuration option `printcap` `name` to the name of a dummy printcap file you provide. In the latter case, the file must contain a series of lines such as:

>     lp|print1|My Printer 1
>     print2|My Printer 2
>     print3|My Printer 3

Each line names a printer followed by aliases for it. In this example, the first printer is called `lp`, `print1`, or `My` `Printer` `1`, whichever the user prefers to use. The first name is used in place of `%p` in any command Samba executes for that printer.

Two additional printer types are also supported by Samba: LPRNG (LPR New Generation) and PLP (Public Line Printer). These are public domain and open source printing systems and are used by many sites to overcome problems with vendor-supplied software. Samba also supports the printing systems of the SOFTQ and QNX real-time operating systems.

### printcap name

If the `printcap` `name` option (also called `printcap`) appears in a printing share, Samba uses the file specified as the system printer capabilities file (normally /etc/printcap). However, you can reset it to a file consisting of only the printers you want to share over the network. The value must be the filename (with its complete path specified) of a printer capabilities file on the server:

>     [deskjet]
>         printcap name = /usr/local/samba/lib/printcap

The CUPS printing system uses its own method of determining printer capabilities, rather than the standard printcap file. In this case, set `printcap` `name` as follows:

>     [global]
>         printing = cups
>         printcap name = cups

### min print space

The `min` `print` `space` option sets the amount of space that must be available on the disk that contains the spool directory if printing is to be allowed. Setting it to zero (the default) turns the check off; setting it to any other number sets the amount of free space in kilobytes required. This option helps to avoid having print jobs fill up the remaining disk space on the server, which can cause other processes to fail:

>     [deskjet]
>         min print space = 4000

### queuepause command

This configuration option specifies a command that tells Samba how to pause an entire print queue, as opposed to a single job on the queue. The default value depends on the printing type chosen. You should not need to alter this option.

### queueresume command

This configuration option specifies a command that tells Samba how to resume a paused print queue, as opposed to resuming a single job on the print queue. The default value depends on the printing type chosen. You should not need to alter this option.

#### Footnotes

> [1] If you are using Linux, you can use the checkpc command to check for this type of error.

> [2] CUPS is open source software (http://www.opensource.org) developed by Easy Software Products. For more information, visit http://www.cups.org.

> [3] We have placed annotated comments off to the right in case you've never dealt with this file before.

#### TOC