An Ubuntu 14.04 which I have been maintaining has a lot of non-working printer configurations. I'd like to purge it all and configure only the working ones from the scratch. Any ideas to remove them all preferably via command line?
Asked
Active
Viewed 2,516 times
2 Answers
4
Stop cupsd:
sudo stop cups
then edit the printer configuration:
sudo cp /etc/cups/printers.conf /etc/cups/printers.conf.backup
sudo nano /etc/cups/printers.conf
Remove all printer information and save.
Jos
- 28,156
- 8
- 82
- 88
-
2For anyone stumbling across this: now you have to do "systemctl stop cups" – Daniel Apr 19 '20 at 12:45
-
1Agreed, we didn't have `systemd` in 2014 :-) – Jos Apr 19 '20 at 15:10
0
This post was first search result on google for me while searching for a way to remove all printers from cups. I'm adding answer from another forum, that I found useful.
Edit 1: Found a small bug while using this command, lpstat -p sometimes print multiple lines for one printer eg.
printer kyocera01 disabled since Št 22. apríl 2021, 12:13:31 -
reason unknown
To fix this, pipe lpstat -p output to grep '^printer' before piping to cut, to filter lines containing printer names.
lpstat -p | grep '^printer' | cut -d' ' -f2
Original answer:
lpstat -p | cut -d' ' -f2 | xargs -I{} lpadmin -x {}
This way you can also filter printers with grep.
lpstat -p | cut -d' ' -f2 | grep mcx | xargs -I{} lpadmin -x {}
Link to original post: https://www.jamf.com/jamf-nation/discussions/11980/removing-printers-with-a-script
Martin Bodický
- 1
- 1