LinuxCommandLibrary

lpoptions

Manage printer options

TLDR

Set the default printer

$ lpoptions -d [printer]/[instance]
copy

List printer-specific options of a specific printer
$ lpoptions -d [printer] -l
copy

Set a new option on a specific printer
$ lpoptions -d [printer] -o [option]
copy

Remove the options of a specific printer
$ lpoptions -d [printer] -x
copy

SYNOPSIS

lpoptions [ options ] [ -d destination | -P printer ] [ -l | -o option[=value]... | -r option... | -x option... ]

PARAMETERS

-E
    Forces encryption when connecting to the server, enhancing security.

-h hostname[:port]
    Specifies an alternate CUPS server to connect to. The default is the local host.

-U username
    Specifies the username to use for authentication with the CUPS server, if required for the operation.

-d destination
    Sets the system default printer for the current user. This updates the user's default printer in ~/.cups/lpoptions.

-P printer[/instance]
    Specifies the printer or class to query or set options for. If this option is omitted, the user's default printer is used.

-l
    Lists the available options and their current settings for the specified printer. This is particularly useful for discovering what options a printer supports.

-o option[=value]
    Sets a printer option for the specified printer or the default printer. If no value is provided, the option is typically enabled (e.g., -o Duplex to enable duplex printing).

-r option
    Resets (removes) a specific printer option from the user's default options for the specified printer. This will cause the system or printer default for that option to be used instead.

-x option
    Deletes the specified option from the user's defaults. This is functionally similar to -r.

DESCRIPTION

The lpoptions command is a utility within the CUPS (Common Unix Printing System) framework. It allows users to manage and view the default printing options for specific printers or classes, or to set a default printer for their user account. These options can include settings like paper size (e.g., PageSize=A4), print quality, duplex printing (e.g., Duplex=DuplexNoTumble), and many others supported by the printer's PPD (PostScript Printer Description) file.

When used without arguments, lpoptions lists the user's current default printer and all its set options. With the -P option, it targets a specific printer. Using -l, it lists all available options and their current settings for a given printer. Options set via lpoptions -o are stored as user-specific defaults, typically in ~/.cups/lpoptions, and will override any system-wide defaults for that user. This command is an essential tool for customizing the printing experience without resorting to graphical interfaces or directly editing configuration files.

CAVEATS

The lpoptions command primarily manages user-specific default printing options, which are stored in ~/.cups/lpoptions. While it can set a default printer for a user, it is not the primary tool for configuring system-wide printer properties or adding/removing printers; for those tasks, lpadmin(8) is used. Changes made with lpoptions will only affect print jobs initiated by the user who executed the command, unless system-wide configuration files (e.g., /etc/cups/lpoptions) are directly modified by an administrator, which is less common via this command.

FILE LOCATIONS

User-specific default options set by lpoptions are stored in the file ~/.cups/lpoptions. This file contains a list of printers and their associated user-defined options. System-wide default options, while generally configured via lpadmin(8), can also be present in /etc/cups/lpoptions, though direct manipulation of this file by lpoptions is less common for non-root users.

EXAMPLES

  • To list all available options for the default printer and their current settings:
    lpoptions -l

  • To list options for a specific printer named 'myprinter':
    lpoptions -P myprinter -l

  • To set the default paper size to A4 and enable duplex printing for 'myprinter':
    lpoptions -P myprinter -o PageSize=A4 -o Duplex=DuplexNoTumble

  • To set 'myprinter' as the default printer for the current user:
    lpoptions -d myprinter

  • To remove the 'PageSize' option from your user-specific defaults for the default printer:
    lpoptions -r PageSize

HISTORY

lpoptions is an integral part of the CUPS (Common Unix Printing System) suite, which was originally developed by Easy Software Products starting in the late 1990s. CUPS was designed to replace older, disparate printing systems on Unix-like operating systems with a modern, standardized, and network-aware architecture. The lpoptions command was introduced as part of this effort, providing a consistent command-line interface for users to manage their printing preferences and defaults, aligning with the modular design of CUPS and its reliance on PPD files for printer capabilities.

SEE ALSO

lp(1), lpadmin(8), cupsd(8), printers.conf(5), cups-files.conf(5)

Copied to clipboard