From: W. Trevor King Date: Fri, 10 Dec 2010 19:55:09 +0000 (-0500) Subject: Add network printer with lpadmin post. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6e568f8401f38c56b92640cfec2d62a58ef4b25d;p=mw2txt.git Add network printer with lpadmin post. --- diff --git a/posts/Adding_a_network_printer_with_lpadmin.mdwn b/posts/Adding_a_network_printer_with_lpadmin.mdwn new file mode 100644 index 0000000..1188013 --- /dev/null +++ b/posts/Adding_a_network_printer_with_lpadmin.mdwn @@ -0,0 +1,66 @@ +Configuring [CUPS][] printers can be a bit of a pain, due to +differences in URIs and drivers depending on the printers make and +model. Many distributions have administrative GUIs that make printer +management easier, and you can usually interact with CUPS through your +browser at `http://localhost:631/admin`, but I prefer using the +command line to get a better feel for the underlying system. + +CUPS has excellent [documentation][]. I found the sections on +[command line and printing options][options] and [configuring network +printers][network] particularly informative. Combined with some +additional browsing and trial and error, here is the procedure to add +a new default network printer, in this case an HP LaserJet 4240 at +123.45.67.89 with [lpadmin][]. + +The basic template for adding and enabling a new printer is + + lpadmin -p printer-name -v device-uri -m model -L location -E + +For `printer-name` and `location`, just pick something that makes +sense to you. `device-uri` will include some extra fluff around your +printer's IP address. Consult the [table][] in the CUPS docs for +ideas or search the net for ideas. For my LaserJet, the URI is +`socket://123.45.67.89`. You can list all device types that CUPS +knows about with [lpinfo][]: + + $ lpinfo -v + … + network socket + … + +Finally, you'll need to figure out which `model` (driver) to use. +`lpinfo` leys you search through available drivers by make and model: + + $ lpinfo --make-and-model 'LaserJet 4042' -m + gutenprint.5.2://hp-lj_4240/expert HP LaserJet 4240 - CUPS+Gutenprint v5.2.5 + gutenprint.5.2://hp-lj_4240/simple HP LaserJet 4240 - CUPS+Gutenprint v5.2.5 Simplified + foomatic:HP-LaserJet_4240-Postscript.ppd HP LaserJet 4240 Foomatic/Postscript + drv:///hpijs.drv/hp-laserjet_4240-hpijs-pcl3.ppd HP LaserJet 4240 hpijs pcl3, 3.10.2 + lsb/usr/hplip/HP/hp-laserjet_4240-ps.ppd HP LaserJet 4240 Postscript (recommended) + +Choices, choices… I've heard good things about [Gutenprint][], so +we'll use that. Not that I ask a lot of a print driver, so perhaps it +would be better to use the recommended ppd file. Just pick something. +If it doesn't work, you can reconfigure with a better driver later. + +Putting it all together, add and enable the new printer: + + $ lpadmin -E -p afmlab -v socket://123.45.67.89 -m gutenprint.5.2://hp-lj_4240/expert -L "LaserJet 4042, Disque 927" -E + +You'll probably also want to make the new printer the default: + + $ lpadmin -d afmlab + +The CUPS daemon will eventually (i.e. after a few seconds) flush these +configuration changes into `/etc/cups/printers.conf` if you prefer +editing text files to the command line or GUI tools ;). + +[CUPS]: http://www.cups.org/ +[documentation]: http://www.cups.org/documentation.php +[options]: http://www.cups.org/documentation.php/doc-1.4/options.html +[network]: http://www.cups.org/documentation.php/doc-1.4/network.html +[lpadmin]: http://www.cups.org/documentation.php/doc-1.4/man-lpadmin.html +[table]: http://www.cups.org/documentation.php/doc-1.4/network.html#TABLE1 +[lpadmin]: http://www.cups.org/documentation.php/doc-1.4/man-lpadmin.html +[lpinfo]: http://www.cups.org/documentation.php/doc-1.4/man-lpinfo.html +[Gutenprint]: http://gimp-print.sourceforge.net/