CUPS with lpq --- another mystery

One can use CUPS via localhost:631 in the browser to check printer queues, but it involves a lot of clicking and there is a simple command
lpq -a
which will list the contents of all printer queues.

Having just conquered an issue with CUPS and my Brother printer in Debian, involving a complete reinstall of both CUPS and the printer drivers, I was dismayed to find that lpq was not working.
The command was present

# which lpq
/usr/bin/lpq

but it did nothing. Normally if all queues are empty it says ‘No entries’

So how come lpq works in Debian on my other machine, and in Devuan, but not in the Debian that I have just reinstalled CUPS in?

It turns out there are two sources of the lpr command… two packages can supply lpr

nevj@trinity:~$ apt-file show lpr
lpr: /etc/cron.weekly/lpr                 
lpr: /etc/default/lpd
lpr: /etc/init.d/lpd
lpr: /etc/logcheck/ignore.d.server/lpr
lpr: /usr/bin/lpq
lpr: /usr/bin/lpr
lpr: /usr/bin/lprm
lpr: /usr/bin/lptest
lpr: /usr/sbin/lpc
lpr: /usr/sbin/lpd
lpr: /usr/sbin/lpf
lpr: /usr/sbin/pac
lpr: /usr/share/doc/lpr/README.Debian
lpr: /usr/share/doc/lpr/changelog.gz
lpr: /usr/share/doc/lpr/copyright
lpr: /usr/share/doc/lpr/examples/printcap
lpr: /usr/share/man/man1/lpq.1.gz
lpr: /usr/share/man/man1/lpr.1.gz
lpr: /usr/share/man/man1/lprm.1.gz
lpr: /usr/share/man/man1/lptest.1.gz
lpr: /usr/share/man/man5/printcap.5.gz
lpr: /usr/share/man/man8/lpc.8.gz
lpr: /usr/share/man/man8/lpd.8.gz
lpr: /usr/share/man/man8/lpf.8.gz
lpr: /usr/share/man/man8/pac.8.gz

and

apt-file show cups-bsd
cups-bsd: /usr/bin/lpq                    
cups-bsd: /usr/bin/lpr
cups-bsd: /usr/bin/lprm
cups-bsd: /usr/sbin/lpc
cups-bsd: /usr/share/doc/cups-bsd
cups-bsd: /usr/share/man/de/man1/lpq.1.gz
cups-bsd: /usr/share/man/de/man1/lpr.1.gz
cups-bsd: /usr/share/man/de/man1/lprm.1.gz
cups-bsd: /usr/share/man/de/man8/lpc.8.gz
cups-bsd: /usr/share/man/fr/man1/lpq.1.gz
cups-bsd: /usr/share/man/fr/man1/lpr.1.gz
cups-bsd: /usr/share/man/fr/man1/lprm.1.gz
cups-bsd: /usr/share/man/fr/man8/lpc.8.gz
cups-bsd: /usr/share/man/man1/lpq.1.gz
cups-bsd: /usr/share/man/man1/lpr.1.gz
cups-bsd: /usr/share/man/man1/lprm.1.gz
cups-bsd: /usr/share/man/man8/lpc.8.gz

I have always installed BOTH packages (lpr and cups-bsd)

ii  lpr                                   1:2008.05.17.3                   amd64        BSD lpr/lpd line printer spooling system

dpkg -l | grep cups-bsd
rc  cups-bsd                              2.3.3op2-3+deb11u2               amd64        Common UNIX Printing System(tm) - BSD commands

It would seem that what ends up in /usr/bin/lpr depends on which package I installed last
and
it probably means I should not have both packages installed
see here

https://unix.stackexchange.com/questions/134083/how-do-i-get-the-right-lpr-for-cups-installed-on-ubuntu-server-14-04

So I did an experiment

root@trinity:~# apt-get purge lpr
root@trinity:~# apt-get purge cups-bsd
root@trinity:~# apt-get install cups-bsd

So now I only have cups-bsd package
Try lpq again

root@trinity:~# lpq -a
no entries

That looks better
Now make another test print and see if lpq sees it

root@trinity:~# lpq -a
Rank    Owner   Job     File(s)                         Total Size
active  unknown 9       unknown                         1024 bytes

Yes it does.

So the answer to the lpq mystery is
use the cups-bsd package with CUPS… do not also install the lpr package
and
what happens if you install both depends on the order in which they are installed. (It would seem I have been lucky with other installs and fluked them in the right order)

Still one question
Does anyone know what the lpr package is used for, if it is not to be used with CUPS?

And one last wish
Could we please have a print system with a few less mantraps, and a package system that tells you what each package is intended to be used for?

3 Likes

Great work…I suspect many of us will benefit from your exploits. :relieved:

1 Like

@nevj

I’m guessing lpr is part of Berkeley printing system. (BSD)

See this forum post for a good explanation.

2 Likes

That post is so good I think we should quote part of it

There are two traditional printing interfaces in the
 unix world: lp (the System V interface) and
 lpr (the BSD interface). There are three printing
 systems available on Linux: the traditional BSD lpr,
 the newer BSD system LPRng, and CUPS. LPRng
 and CUPS both provide a BSD-style interface and
 a System-V-style interface.

No wonder I have been doing it wrong for 10 years
Thanks
Neville

1 Like