Go to main content

Configuring and Managing Printing in Oracle® Solaris 11.3

Exit Print View

Updated: December 2017
 
 

Setting a Default Printer

You can specify the default printer in one of the following ways:

  • By setting the LPDEST or PRINTER environment variable.

    The LPDEST environment variable determines the destination of the printer. If the LPDEST variable is not set, the PRINTER variable is used. The PRINTER variable determines the output device or destination. For instructions on setting up a default printer by specifying the environment variables, see How to Set a Default Printer at the Command Line.

  • By using the new lpoptions command.

    Use this command to display or set printer options and defaults. For instructions on setting up a default printer by using the CUPS commands, see How to Set a Default Printer at the Command Line. For more information, see the lpoptions(1) man page.

  • By using the lpadmin command.

The print command searches for the default printer in the following order:

  1. The printer name as set by the lp command with the –d option

  2. The value of the LPDEST environment variable

  3. The value of the PRINTER environment variable

  4. The printer name as set by the lpoptions command

  5. The printer name as set by the lpadmin command

For instructions on setting up printers by using the CUPS web browser interface, see Setting Up and Administering Printers by Using the CUPS Web Browser Interface.

How to Set a Default Printer at the Command Line

The default printer can be a local printer or a remote printer.

  1. Set the user 's default printer by using one of the following methods:
    • By specifying the PRINTER variable:
      $ export PRINTER=printer-name

      where printer-name specifies the name of the printer to be assigned as the user's default printer.


      Note -  When using the lp command with the –d option, the destination printer, which might not be the default printer, is specified. If the –d option is not specified, the print command searches for information about the printer in the PRINTER environment variable.
    • By specifying the LPDEST variable:
      $ export LPDEST=printer-name

      where printer-name specifies the name of the printer to be assigned as the default printer.


      Note -  If both the LPDEST and the PRINTER environment variables are set, LPDEST takes precedence.
    • By using the lpoptions command:
      $ lpoptions -d printer-name
      –d

      Specifies the destination printer.

      printer-name

      Specifies the name of the printer that is assigned as the user 's default printer.

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

  2. Verify the default printer.
    $ lpstat -d
  3. To print to the default printer, type the following command:
    $ lp filename
Example 4  Setting a Default Printer by Specifying the PRINTER Variable

The following example shows how to set the printer luna as the default printer by using the PRINTER variable.

$ export PRINTER=luna
$ lpstat -d
system default destination: luna
Example 5  Setting a Default Printer by Specifying the LPDEST Variable

The following example shows how to set the printer luna as the default printer by specifying the LPDEST variable.

$ export LPDEST=luna
$ lpstat -d
system default destination: luna
Example 6  Setting a Default Printer by Using the lpoptions Command

The following example shows how to set the printer luna as the default printer. The printer luna is used as the default printer if the LPDEST or the PRINTER environment variable is not set.

$ lpoptions -d luna
$ lpstat -d
system default destination: luna

The lpoptions command creates a ~/.cups/lpoptions file that includes an entry for the default printer luna in the file. By default, all print jobs are now directed to the luna printer. For a root user, the lpoptions command creates a /etc/cups/lpoptions file.

Example 7  Setting a Default Printer by Using the lpadmin Command

The following example shows how to set the printer luna as the default printer by using the lpadmin command.

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

How to Print to a Specified Printer

  1. (Optional) Verify the status of the printer.
    $ lpstat -p printer-name
  2. Provide the destination printer name when issuing the lp command.
    $ lp -d destination-printer filename
    –d

    Specifies the destination printer.

    destination-printer

    Specifies the name of the printer that you are assigning as the destination printer.

    filename

    Specifies the file name to print.


    Note -  You can also use the lpr command with the –P option to submit a print request to a specific printer. For more information, see the lpr(1) man page.
Example 8  Printing to a Specified Printer by Using the lp Command

The following example shows how to set the printer luna as the destination printer.

$ lp -d luna abc.ps
request id is luna-1 (1 file(s))

$ lpstat -d
system default destination: saturn

The –d option of the lp command takes precedence over default printer settings.

Note that in this example, the default printer is saturn.