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:
The printer name as set by the lp command with the –d option
The value of the LPDEST environment variable
The value of the PRINTER environment variable
The printer name as set by the lpoptions command
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 .
The default printer can be a local printer or a remote printer.
$ export PRINTER=printer-name
where printer-name specifies the name of the printer to be assigned as the user's default printer.
$ export LPDEST=printer-name
where printer-name specifies the name of the printer to be assigned as the default printer.
$ lpoptions -d printer-name
Specifies the destination printer.
Specifies the name of the printer that is assigned as the user 's default printer.
For more information, see the lpoptions(1) man page.
$ lpstat -d
$ lp filename
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: lunaExample 2-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: lunaExample 2-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 2-7 Setting a Default Printer by Using the lpadmin CommandThe 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
$ lpstat -p printer-name
$ lp -d destination-printer filename
Specifies the destination printer.
Specifies the name of the printer that you are assigning as the destination printer.
Specifies the file name to print.
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.