System Administration Guide: Printing

Chapter 6 Administering Printers by Using LP Print Commands (Tasks)

This chapter describes how to administer printers by using LP print commands.

This is a list of the information that is in this chapter:

For overview information about printing, see Chapter 1, Introduction to Printing in the Oracle Solaris Operating System.

Administers Printers Using LP Print Commands (Task Map)

Table 6–1 Printer Administration by Using LP Print Commands (Task Map)

Task 

Description 

For Instructions 

Add a printer description. 

Use the lp command with the-p option to add a printer description.

How to Add a Printer Description by Using LP Print Commands

Set a default printer for a system. 

Specify a default printer destination for a user so the user does not need to type the printer name. 

How to Set a System's Default Printer Destination by Using LP Print Commands

Make banner pages optional. 

Give users a choice to turn off printing of a banner page when they submit a print request.  

How to Make Banner Pages Optional by Using LP Print Commands

Turn off banner pages. 

Set the -o banner=never variable for a printer you can turn off banner pages under all circumstances.

How to Turn Off Banner Pages by Using LP Print Commands

Define a class of printers. 

Group printers in a class by using the lpadmin -c command.

Printers can be grouped in the following classes:

  • Printer type

  • Location

  • Work group

How to Define a Class of Printers by Using LP Print Commands

Set fault alters for a printer. 

The print service can notify you when it detects a printer fault. Use the -A option with the lpadmin command to set fault alerts for a printer.

How to Set Fault Alerts for a Printer by Using LP Print Commands

Set printer fault recovery. 

You can choose not to receive any fault notification. You can find out about printing faults so that you can correct the problem. Use the -F option with the lpadmin command to define fault recovery options.

How to Set Printer Fault Recovery by Using LP Print Commands

Limit user access to a printer. 

To control user access to printers, create allow and deny lists on the print server. 

How to Limit User Access to a Printer by Using LP Print Commands

Setting Printer Definitions by Using LP Print Commands

Setting definitions for the printers on your network is an ongoing task that lets you provide a more effective print environment for users. For example, you can assign printer descriptions for all your site's printers to help users find where a printer is located. Or, you can define a class of printers to provide the fastest turnaround for print requests. See Specifying a PPD File When Setting Up a Printer for more information about setting printer definitions by using LP print commands.

Many printer definitions can be set or reset by using Solaris Print Manager. For more information, see Setting Printer Definitions by Using Solaris Print Manager.

The following procedures provide step-by-step instructions on setting or resetting printer definitions by using LP Print Commands. These procedures show how to quickly set or reset printer definitions.

ProcedureHow to Add a Printer Description by Using LP Print Commands

  1. Log in as superuser, lp, or assume an equivalent role on the print server.

  2. Add a printer description.


    # lpadmin -p printer-name -D "comment"
    -p printer-name

    Specifies the name of the printer for which you are adding a description.

    -D "comment"

    Specifies the characteristics of the printer, such as the location or administrative contact. Enclose characters that the shell might interpret, such as *, ?, \, !, ^, in single quotation marks.

    For more information, see the lpadmin(1M) man page.

  3. Verify that the Description information is correct.


    # lpstat -p printer-name -l
    

Example 6–1 Adding a Printer Description

The following example shows how to add a printer description for the printer luna.


# lpadmin -p luna -D "Nathans office"

Setting Up a Default Printer Destination by Using LP Print Commands

You can specify a default printer destination for a user so that the user does not need to type the printer name when using the print commands. Before you can designate a printer as the default, the printer must be known to the print service on the system.

Set a user's default printer destination by setting any of the following:

When an application provides a printer destination, that destination is used by the print service, regardless of whether you have set a system's default printer destination. If an application doesn't provide a printer destination or if you do not provide a printer name when using a print command, the print command searches for the default printer in a specific order. The following table shows the search order for a system's default printer destination.

Table 6–2 Search Order for Default Printer Destinations

Search Order 

Using /usr/bin/lp Command

Using LPD-Based Compatible Commands (lpr, lpq, and lprm)

First 

LPDEST variable

PRINTER variable

Second 

PRINTER variable

LPDEST variable

Third 

System's default printer 

System's default printer 

ProcedureHow to Set a System's Default Printer Destination by Using LP Print Commands

  1. Log in as superuser, lp, or assume an equivalent role on the system where you want to set a default printer.

  2. Set the system's default printer.


    # lpadmin -d [printer-name]

    -d printer-name specifies the name of the printer you are assigning as the system's default printer. If you don't specify printer-name, the system is set up with no default printer.

  3. Check the system's default printer.


    # lpstat -d
    

Example 6–2 Setting a System's Default Printer Destination

The following example shows how to set the printer luna as the system's default printer. The printer luna is used as the system's default printer if the LPDEST or the PRINTER environment variables are not set.


# lpadmin -d luna
# lpstat -d
system default destination: luna

Printing Banner Pages by Using LP Print Commands

A banner page identifies who submitted the print request, the print request ID, and when the request was printed. A banner page also has a modifiable title to help users identify their printouts.

Banner pages make it easy to identify the owner of a print joby, which is especially helpful when many users submit jobs to the same printer. However, printing banner pages uses more paper and might be unnecessary if a printer has only a few users. In some cases, printing banner pages is undesirable. For example, if a printer has special paper or forms mounted, such as paycheck forms, printing banner pages might cause problems.

By default, the print service forces banner pages to be printed. However, you can give users a choice to turn off printing of a banner page when they submit a print request. You can set this choice through the lpadmin command or through Solaris Print Manager. If you give the users a choice, they have to use the -o banner option to turn off banner page printing.

Also, if you don't need or want banner pages, you can turn off banner pages so that they are never printed. You can turn off banner page printing by using the lpadmin command or through Solaris Print Manager.

The following table describes command options that are used to manage banner page printing.

Table 6–3 Banner Page Printing

Command Used 

Banner Page Printing 

Override? 

lpadmin -p printer -o banner OR

lpadmin -p printer -o banner=always

Required and printed 

If you are a regular user and use -o nobanner, the request is printed. However, the nobanner argument is ignored.

If you are superuser (root), or another privileged user, the nobanner argument is honored.

lpadmin -p printer -o nobanner

lpadmin -p printer -o banner=optional

On by default, but can be disabled on a per request basis with the lp -o nobanner command

Not applicable 

lpadmin -p printer -o banner=never

Disabled 

No, if you are a regular user. If you are superuser (root), or the lp user, you can override this option to cause the generation of a burst page.

ProcedureHow to Make Banner Pages Optional by Using LP Print Commands

  1. Log in as superuser, lp, or assume an equivalent role on the print server.

  2. Make banner pages optional.


    # lpadmin -p printer-name -o banner=optional
    
    -p printer-name

    Specifies the name of the printer for which you are making banner pages optional.

    -o banner=optional

    Enables users to specify no banner page when they submit a print request.

  3. Verify that the banner page is optional. The command output contains the line Banner not required.


    # lpstat -p printer-name -l
    

Example 6–3 Making Banner Pages Optional

The following example shows how to make the banner page optional on the printer luna.


# lpadmin -p luna -o banner=optional

ProcedureHow to Turn Off Banner Pages by Using LP Print Commands

  1. Log in as superuser, lp, or assume an equivalent role on the print server.

  2. Turn off banner printing.


    # lpadmin -p printer-name -o banner=never
    
    -p printer-name

    Specifies the name of the printer for which you are turning off banner pages.

    -o banner=never

    Disables banner page printing under all circumstances.

  3. Verify that banner printing is turned off.


    # lpstat -p printer-name -l
    

    The command output contains the line Banner not printed.

  4. Submit a print request to the printer to ensure that a banner page does not print.


Example 6–4 Turning Off Printing Banner Pages

The following example shows how to disable the printing of banner pages on the printer luna.


# lpadmin -p luna -o banner=never

Setting Up Printer Classes by Using LP Print Commands

The LP print service enables you to group several locally attached printers into one class. You can perform this task only by using the lpadmin -c command.

After you set up a printer class, users can then specify that class, rather than individual printers, as the destination for a print request. The first printer in the class that is available to print is used. The result is faster turnaround because printers are kept as busy as possible.

No default printer classes are known to the print service. Printer classes exist only if you define them.

Here are some ways you could define printer classes:

Alternatively, a class might contain several printers that are used in a particular order. The LP print service always checks for an available printer in the order in which printers were added to a class. Therefore, if you want a high-speed printer to be accessed first, add the high-speed printer to the class before you add a low-speed printer. As a result, the high-speed printer handles as many print requests as possible. The low-speed printer is reserved as a backup printer when the high-speed printer is in use.


Note –

Print requests are balanced between printers in a class only for local printers.


Class names, similar to printer names, must be unique and can contain a maximum of 14 alphanumeric characters and underscores.

You are not obligated to define printer classes. You should add printer classes only if you determine that using them would benefit users on the network.

ProcedureHow to Define a Class of Printers by Using LP Print Commands

  1. Log in as superuser, lp, or assume an equivalent role on the print server.

  2. Define a class of printers.


    # lpadmin -p printer-name -c printer-class
    
    -p printer-name

    Specifies the name of the printer you are adding to a class of printers.

    -c printer-class

    Specifies the name of a class of printers.

  3. Verify that the printers are in a printer class.


    # lpstat -c printer-class
    

Example 6–5 Defining a Class of Printers

The following example shows how to add the printer luna in the printer class roughdrafts.


# lpadmin -p luna -c roughdrafts

Setting Up Printer Fault Alerts by Using LP Print Commands

If you choose, the LP print service can notify you when it detects a printer fault. With the lpadmin -A command or with Solaris Print Manager, you can select any of the following methods to receive printer fault notification:

However, the lpadmin -A command offers you an additional option of receiving a message specified by the program of your choice. The lpadmin -A command also enables you to selectively turn off notification for an error that you already know about.

Unless you specify a program to deliver fault notification, the content of the fault alert is a predefined message that states that the printer has stopped printing and needs to be fixed.

The following table lists the alert values that you can set for a printer with the lpadmin -A command. These alert values can also be set for print wheels, font cartridges, and forms.

Table 6–4 Values for Printer Fault Alerts

Value for -A alert

Description 

'mail [username]'

Sends the alert message by email to root or lp on the print server, or the specified username, which is a name of a user.

'write [user-name]'

Sends the alert message to the root or lp console window on the print server, or to the console window of the specified username, which is a name of a user. The specified user must be logged in to the print server to get the alert message.

'command'

Runs the specified command file for each alert. The environment variables and current directory are saved and restored when the file is executed.

quiet

Stops alerts until the fault is fixed. Use this valve when you, root or a specified user, receive repeated alerts.

none

Does not send any alerts. This value is the default if you don't specify fault alerts for a printer. 

ProcedureHow to Set Fault Alerts for a Printer by Using LP Print Commands

  1. Log in as superuser, lp, or assume an equivalent role on the print server.

  2. Set fault alerts for a printer.


    # lpadmin -p printer-name -A alert [-W minutes]
    -p printer-name

    Specifies the name of the printer for which you are specifying an alert for printer faults.

    -A alert

    Specifies what kind of alert occurs when the printer faults. Some valid values are mail, write, and quiet.

    -W minutes

    Specifies how often, in minutes, the fault alert occurs. If you don't specify this option, the alert is sent one time.

  3. Verify that the fault alert has been sent properly.


    # lpstat -p printer-name -l
    

Example 6–6 Setting Fault Alerts for a Printer

The following example shows how to set up the printer mars to send fault alerts by email to a user named joe. A reminder is sent every 5 minutes.


# lpadmin -p mars -A 'mail joe' -W 5

The following example shows how to set up the printer venus to send fault alerts to the console window. A reminder i sent every 10 minutes.


# lpadmin -p venus -A write -W 10

The following example shows how to stop fault alerts for the printer mercury.


# lpadmin -p mercury -A none

The following example shows how to stop fault alerts until the printer venus has been fixed.


# lpadmin -p venus -A quiet

Setting Up Printer Fault Recovery by Using LP Print Commands

If you choose not to send any fault notification, you can still find out about printer faults so that you can correct the problem. The LP print service will not continue to use a printer that has a fault. In addition to alerts for printer faults, you can also provide alerts that instruct you to mount print wheels, font cartridges, and forms when print requests require them.

You can define the fault recovery options for a printer only by using the lpadmin -F command. This task is not available in Solaris Print Manager.

Printer faults can be as simple as running out of paper or needing to replace a toner cartridge. More serious problems can include complete printer failure or power failure.

After you fix a printer fault, the print request that was active when the fault occurred begins printing in one of three ways:

The LP print service requires a separate print filter to continue printing from the top of a page where the printing stopped. This print filter records the control sequences set by the default print filters. The printer uses these control sequences to track page boundaries. You will be notified by the LP print service if recovery cannot proceed with the specified print filter. For information about writing filters, see How to Create a New Print Filter.

If you want printing to resume immediately after a printer fault is fixed, enable the printer by using the enable command.

The following table lists the fault recovery values that you can set for a printer by using the lpadmin -F command.

Table 6–5 Values for Printer Fault Recovery

Value for -F recover-options

Description 

beginning

After a fault recovery, printing restarts from the beginning of the file. 

continue

After a fault recovery, printing starts at the top of the page where the printing stopped. This recovery option requires a print filter.

wait

After a fault recovery, printing stops until you enable the printer. After you enable the printer by using the enable command, printing starts at the top of the page where printing stopped. This recovery option requires a print filter.

ProcedureHow to Set Printer Fault Recovery by Using LP Print Commands

  1. Log in as superuser, lp, or assume an equivalent role on the print server.

  2. Set up fault recovery for the printer.


    # lpadmin -p printer-name -F recovery-options
    
    -p printer-name

    Specifies the name of the printer for which you are specifying fault recovery.

    -F recovery-options

    Specifies one of the three valid recovery options: beginning, continue, or wait.

    For more information, see the lpadmin(1M) man page.

  3. Verify that printer fault recovery has been set up properly.


    # lpstat -p printer-name -l
    

Example 6–7 Setting Printer Fault Recovery

The following example shows how to set up the printer luna to continue printing at the top of the page where printing stopped.


# lpadmin -p luna -F continue

Limiting User Access to a Printer by Using LP Print Commands

You can control which users can access some printers or all of the available printers. For example, you can prevent some users from printing on a high-quality printer to minimize expense. To restrict user access to printers, you create allow and deny lists by using the lpadmin -u command on the print server. Solaris Print Manager enables you to create only allow lists. If you create neither list, a printer is available to all users who can access the printer.

An allow list contains the names of users who are allowed access to the specified printer. A deny list contains the names of users denied access to the specified printer.

The rules for allow and deny lists are explained in the following table:

Allow and Deny List Rule 

User Consequence 

Do not create allow and deny lists. Or, if you leave both lists empty.

All users can access the printer. 

Specify all in the allow list.

All users can access the printer. 

Specify all in the deny list

All users, except root and lp user on the server, are denied access to the printer.

Make any entry in the allow list.

The deny list is ignored. Only users who are listed can access the printer.

Create a deny list, but you do not create an allow list or you leave the allow list empty.

Users who are listed in the deny list are denied access to the printer.

Because the print server is responsible for controlling access to the printer, allow and deny lists can only be created on the print server. If you create allow and deny lists, the print server will exclusively control user access to printers.

The following table lists the values that you can add to an allow list or a deny list to limit user access to a printer.

Table 6–6 Values for Allow and Deny Lists

Value for user-list

Description 

user

User on any system

all

All users on all systems 

none

No user on any system 

system!user

User on system only

!user

User on local system only

all!user

User on any system

all!all

All users on all systems 

system!all

All users on system

!all

All users on local system 

ProcedureHow to Limit User Access to a Printer by Using LP Print Commands

  1. Log in as superuser, lp, or assume an equivalent role on the print server.

  2. Allow or deny users access to a printer.


    # lpadmin -p printer-name -u allow:user-list [deny:user-list]
    -p printer-name

    Specifies the name of the printer to which the allow or deny access list applies.

    -u allow:user-list

    Specifies the user names to be added to the allow access list. You can specify multiple user names with this command. Use a space or a comma to separate names. If you use spaces, enclose the list of names in quotation marks.

    -u deny:user-list

    Specifies user names to be added to the deny user access list. You can specify multiple user names with this command. Use a space or a comma to separate names. If you use spaces, enclose the list of names in quotation marks.

    The specified users are added to the allow or deny list for the printer in one of the following files on the print server:


    Note –

    If you specify none as the value for user-list in the allow list, the following files are not created on the print server:


  3. Verify that information is correct under the Users allowed or the Users denied heading in the following command output:


    # lpstat -p printer-name -l
    

Example 6–8 Limiting User Access to a Printer

The following example shows how to allow only the users nathan and george access to the printer luna.


# lpadmin -p luna -u allow:nathan,george

The following example shows how to deny the users nathan and george access to the printer asteroid.


# lpadmin -p asteroid -u deny:"nathan george"

Administering Printers That Are Associated With PPD Files (Task Map)

Table 6–7 Administering Printers Associated With PPD Files (Task Map)

Task 

Description 

Description 

Set definitions for print queues that use PPD files. 

Modify the default values that are defined in PPD files that are associated with print queues by using the lpadmin command with the -o option.

How to Set Default Values for Print Queues That Are Associated With PPD Files

Determine if a PPD file was used to create a print queue. 

Use the lpstat command to determine if a PPD file was used to create a print queue, or if a PPD file is associated with a print queue.

Determining Whether a PPD File Is Associated With a Print Queue

Administering Printers That are Associated With PPD Files

During the process of setting up a print queue, a PPD file that describes the print queue's capabilities can be associated with that print queue. Often, the default values that are described in the PPD file do not match the preferred settings for your site. For example, you might want the duplex feature always turned on, or you might want to always print to A4 sized paper. To modify these default values, you can edit the PPD file directly. However, the easiest and fastest method is to make the changes by using the lpadmin command with the -o option.

Some common PPD file values include:

ProcedureHow to Set Default Values for Print Queues That Are Associated With PPD Files

This procedure shows how to set default values for a print queue that uses PPD files to describe its capabilities.

Before You Begin

Check the PPD file first to determine which values can be overridden. To view information about the PPD file, use the more or less command, or open the file in a text editor.

For example:


$ more /etc/lp/ppd/print-queue.ppd
  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Set the desired option.


    # lpadmin -p print-queue -o key=value
    
    -p

    Specifies the printer name or print queue where the value is to be changed.

    -o

    Specifies the options for adjusting printer capabilities, adjusting printer port characteristics, configuring network printers, and controlling the use of banner.

    key=value

    Specifies the key/value pair for the option.

    The set of key/value pairs that can be used for a particular printer depends on the content of the PPD file that is associated with the print queue.

    For example, to set the duplex feature, type:


    # lpadmin -p print-queue -o Duplex=DuplexNoTumble
    

    To change the input tray setting, type:


    # lpadmin -p print-queue -o InputSlot=Tray2
    

    You can set the default value this way for any PPD file/foomatic option.

  3. Verify that the option was set to the correct value by checking the print queue's capabilities.


    # lpstat -p print-queue -l
    

Example 6–9 Setting Values for Print Queues That Use PPD Files


# lpadmin -p hp4550 -o Media=A4 -o InputSlot=Tray2
# lpadmin -p hp4550 -o PageSize=A4
# lpstat -p hp4550 -l
printer hp4550 idle. enabled since December  5, 2006  6:38:50 PM CET. available.
        Form mounted:
        Content types: application/postscript
        Description:
        Connection:
 Interface: /usr/lib/lp/model/netstandard_foomatic
        PPD: /usr/lib/lp/model/ppd/system/foomatic/ \
HP/HP-Color_LaserJet_4550-Postscript.ppd.gz
        On fault: write root
        After fault: continue
        Users allowed:
                (all)
        Forms allowed:
                (none)
        Media supported:
                Letter
                A4
                11x17
                A3
                A5
                B5
                Env10
                EnvC5
                EnvDL
                EnvISOB5
                EnvMonarch
                Executive
                Legal
        Banner not required
        Character sets:
                (none)
        Default pitch:
        Default page size:
        Default port setting:
        Options: PageSize=A4, Media=A4, InputSlot=Tray2, \
dest=192.168.245.62:9100, protocol=tcp
# uname -a
SunOS shuttle 5.11 snv_52 i86pc i386 i86pc
# lpstat -p hp4550 -l
printer hp4550 idle. enabled since December  5, 2006  6:38:50 PM CET. available.
        Form mounted:
        Content types: application/postscript
        Description:
        Connection:
        Interface: /usr/lib/lp/model/netstandard_foomatic
        PPD: /usr/lib/lp/model/ppd/system/foomatic/ \
HP/HP-Color_LaserJet_4550-Postscript.ppd.gz
        On fault: write root
        After fault: continue
        Users allowed:
                (all)
        Forms allowed:
                (none)
        Media supported:
                Letter
                A4
                11x17
                A3
                A5
                B5
                Env10
                EnvC5
                EnvDL
                EnvISOB5
                EnvMonarch
                Executive
                Legal
        Banner not required
        Character sets:
                (none)
        Default pitch:
        Default page size:
        Default port setting:
        Options: dest=192.168.245.62:9100, protocol=tcp

Determining Whether a PPD File Is Associated With a Print Queue

If a PPD file was used during the creation of a print queue, the PPD file that the specified queue is configured to use is listed in the lpstat command output. If you do not specify a PPD file when creating a new print queue, the lpstat command continues to display the same output as it did previously. For an example of the lpstat command output that shows the use of PPD files, see How to Check the Status of Printers.


Example 6–10 Displaying Information About a PPD File by Using the lpstat Command

In this example, the lpstat command output indicates that the print queue was configured by using the PPD file, Mitsubishi-CP50_Color_Printer-cp50.ppd.gz.


# lpstat -l -p paper
printer paper is idle. enabled since Tue 30 Mar 2004 01:48:38 PM PST
			available.
        Form mounted: 
        Content types: any
        Printer types: unknown
        Description: 
        Connection: direct
        Interface: /usr/lib/lp/model/standard_foomatic
        PPD: /path/Mitsubishi-CP50_Color_Printer-cp50.ppd.gz
        After fault: continue
        Users allowed:
                (all)
        Forms allowed:
                (none)
        Banner required
        Character sets:
                (none)
        Default pitch:
        Default page size:
        Default port settings# lpstat l p <queue>