49

I need a command to list available printers in my Ubuntu.

The printers list could be installed or shared?

This list also should state the state of the printer .

Any Help to achieve my goal?

nux
  • 39,152

4 Answers4

52

The Command lpstat -p will list all available printers for your Desktop .

And whether or not they are available ( the state of them) .

Luis Alvarado
  • 216,643
nux
  • 39,152
17

If you just want the printer names:

lpstat -p | grep '^printer' | awk '{print $2}'

To see their names and print queues:

lpstat -p | grep '^printer' | awk '{print $2}' | xargs -n1 lpq -P
DanB
  • 914
5

I need a command to list available printers in my Ubuntu.

I have bolded available because the OP presumably means that.

Neither lpstat -p nor lpstat -t list all printers available on the local network. Both commands only show local (often called permanent) printers. Both appear to have gained some traction as inadequate responses to the query.

As of 2022, lpstat -e or lpstat -l -e give all available on the local network.

brian_p
  • 916
3

For the most detailed information about all available printers including local and lan printers, you can use -t option with lpstat

It tells you the following:

  1. Scheduler information
  2. Default printer
  3. Addresses of the printers
  4. Enabled status with timestamp
  5. Accepting jobs status with timestamp
  6. If a printer is currently printing

Here is the sample output

> lpstat -t

scheduler is running system default destination: HP_Ink_Tank_Wireless_410_series_1C5045 device for Deskjet-Ink-Adv-2010-K010: hp:/usb/Deskjet_Ink_Adv_2010_K010?serial=CN12C11MQH05MB device for HP_Ink_Tank_Wireless_410_series_1C5045: implicitclass://HP_Ink_Tank_Wireless_410_series_1C5045/ Deskjet-Ink-Adv-2010-K010 accepting requests since Saturday 30 April 2022 10:45:04 AM HP_Ink_Tank_Wireless_410_series_1C5045 accepting requests since Monday 02 May 2022 01:54:54 PM printer Deskjet-Ink-Adv-2010-K010 is idle. enabled since Saturday 30 April 2022 10:45:04 AM printer HP_Ink_Tank_Wireless_410_series_1C5045 now printing HP_Ink_Tank_Wireless_410_series_1C5045-202. enabled since Monday 02 May 2022 01:54:54 PM HP_Ink_Tank_Wireless_410_series_1C5045-202 user 679936 Monday 02 May 2022 01:54:54 PM