The lpadmin
command is used to configure printers and classes in the Common Unix Printing System (CUPS) suite. It allows system administrators to add, modify, or delete printers and classes, as well as set various printer options such as page size, print quality, and printer sharing.
Overview
To use lpadmin
, you must have administrative privileges on the system. The basic syntax of the command is as follows:
lpadmin [options] -p printer-name -E -v device-uri
Here, printer-name
is the name of the printer you want to configure, and device-uri
is the URI of the printer device. The -E
option enables encryption for the printer connection.
To add a new printer, use the -p
option followed by the printer name, and then specify the printer device using the -v
option. For example:
lpadmin -p printer1 -E -v socket://192.168.1.10:9100
This command adds a new printer named “printer1” and sets its device URI to “socket://192.168.1.10:9100”.
You can also set various printer options using the -o
option. For example, to set the page size to A4 and the print quality to 600 dpi, use the following command:
lpadmin -p printer1 -o PageSize=A4 -o PrintQuality=600dpi
To delete a printer, use the -x
option followed by the printer name. For example:
lpadmin -x printer1
This command deletes the printer named “printer1”.
Options
Here is a list of available options for lpadmin
:
Option | Description |
---|---|
-p printer-name |
Specifies the name of the printer to configure. |
-E |
Enables encryption for the printer connection. |
-v device-uri |
Specifies the URI of the printer device. |
-o option=value |
Sets a printer option to the specified value. |
-x printer-name |
Deletes the specified printer. |
-d printer-name |
Sets the default printer to the specified printer. |
-c class-name |
Creates a printer class with the specified name. |
-r class-name |
Removes the specified printer class. |
-A |
Allows all users to print to the specified printer. |
-U username |
Allows the specified user to print to the specified printer. |
-u allow:username |
Allows the specified user to modify the specified printer. |
-u deny:username |
Denies the specified user from modifying the specified printer. |
Troubleshooting tips
- If you encounter permission errors, make sure you are running the command with administrative privileges.
- If you are having trouble connecting to a network printer, make sure the printer device URI is correct and that the printer is turned on and connected to the network.
- If you are having trouble setting printer options, make sure the option names and values are correct and supported by the printer driver.
Notes
lpadmin
is part of the CUPS suite, which is the default printing system on most Linux distributions.- The
lpadmin
command can be used in scripts and other automated processes to configure printers and classes. - The
lpadmin
command can be used in conjunction with other CUPS utilities, such aslpstat
andcancel
, to manage printing jobs and queues.