It is very difficult for me to perform printing, because the printer dialogue is full of hundreds of automatically added printers, so I can't find the one I want to use, see screenshot below.
The printers stem from my work network, where apparently lots of people (including students, I guess) are "sharing" their home printers, which my laptop then picks up automatically. (coincidentally I sometimes disable the avahi-daemon at work, simply because it is using a large amount of CPU).
When I go to http://localhost:631/printers/
, it says there are 131 printers, and they are all of Make and Model 'Local Raw Printer'. With two exceptions: 1 is a network printer at work that I manually configured. Another is a network printer at my parents', which was also automatically added and which I am on the same network as right now. But the rest are just garbage that I would really like to avoid. Tips on how to do that would be appreciated.
I will not be going back to my work place for a bit of time though, so for now, I would just like these printers (that would be the 129/130 automatically added printers) to be removed. Is there a way to do that? I guess I could do it by clicking through in the cups web interface, but for 129 printers, that is a bit much. So I am looking for a single command or tips on how to achieve it with a script of sorts.
Using this command:
lpstat -a
we can see the installed printers and identify the name of the desired printer to keep, we can use thegrep
command also to filter the results like so:lpstat -a | grep <probable_name_of_printer>
.Then this little script can help:
Run this command to check that the desired printer is not listed:
This should return nothing as it does the following:
lpstat -a
: list installed printerscut -d" " -f1
: return only the names of the printerssed -E '/<NAME_OF_PRINTER>/d'
: remove the name of the printer to keep from the output of the previous commandsgrep <NAME_OF_PRINTER>
: make sure the desired printer is not on the listIf the above checks out; then run this command to remove every other printer that you don't need: