Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The lpr man page says a destination printer can be specified with the -P flag.

-P destination[/instance]
    Prints files to the named printer.

I have 'added' various printers on local Samba shares using the GUI in Ubuntu/Gnome. How can I get a list of these available printers in the format that the -P flag expects (preferably from a bash shell)?

share|improve this question
up vote 34 down vote accepted
$ lpstat -p -d

From the CUPS manual.

share|improve this answer
Thank you! I've just found that lpq works too. – Ian Mackinnon Aug 18 '10 at 16:56
Whenever I'm looking for this, I'm also looking for how to pick a default printer: lpoptions -d printername – Joshua Goldberg Oct 26 '15 at 19:29

I am using lpstat -a to parse only the printer names:

lpstat + awk:

$ lpstat -a | awk '{print $1}'

lpstat + cut:

$ lpstat -a | cut -f1 -d ' '

Another option would be to get it from /etc/printcap:

$ cat /etc/printcap | cut -f1 -d'|' | grep '^#' -v

Both commands will yield only the printer name, one per line:


I feel like the lpstat solution is more elegant and reliable. Mostly because /etc/printcap is auto-generated by cups and I am not sure it will always show the available printers. About using AWK or cut, depends on what you have installed and prefer.

The marked solution does no work for me on Amazon Linux. Maybe CUPS changed since 2010/11?

$ lpstat -p -d
printer HP_Deskjet_2540_series is idle. enabled since Tue 22 Dec 2015 01:12:10 PM BRST
. . .
printer GCP-Save_to_Google_Docs is idle. enabled since Tue 15 Dec 2015 02:13:33 AM BRST
system default destination: HP_LaserJet_P1606dn
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.