As this contains a lot of info concerning the CUPS's "lpr" command, a lot here should work on all other unices and Linux.
---------------------------------------------------
Creating a ppd for desired printer
=============================================
$ foomatic-ppdfile -P 2850
Samsung ML-2850D Id='Samsung-ML-2850D' Driver='Postscript' CompatibleDrivers='Postscript pxlmono '
$ foomatic-ppdfile -p 'Samsung-ML-2850D' -d 'Postscript' > samsung-ml2850d.ppd
-----------------------------------------------------
Adding a printer to cups from command line
# lpinfo -v (prints accessible destinations)
direct hp
network smb
direct hpfax
network socket://10.0.0.22
# lpinfo --make-and-model "LaserJet 4000" -m (shows usable printer drivers)
foomatic-db-compressed-ppds:0/ppd/foomatic-ppd/HP-LaserJet_4000-lj5gray.ppd HP LaserJet 4000 Foomatic/lj5gray
foomatic-db-compressed-ppds:0/ppd/foomatic-ppd/HP-LaserJet_4000-Postscript.ppd HP LaserJet 4000 Foomatic/Postscript
foomatic-db-compressed-ppds:0/ppd/foomatic-ppd/HP-LaserJet_4000-pxlmono.ppd HP LaserJet 4000 Foomatic/pxlmono
# lpadmin -p myprinter -v network socket://10.0.0.22:9100 -m foomatic-db-compressed-ppds:0/ppd/foomatic-ppd/HP-LaserJet_4000-lj5gray.ppd -E
or potentialy with a ready to go ppd in my file:
# lpadmin -p myprinter -v network socket://10.0.0.22:9100 -P /home/bob/hp_laser.ppd -E
# lpstat -a (to check - shows available printers)
# lpstat -t (to see details about my printers)
-----------------------------------------------------
lpstat options
-t : show all CUPS info
-d : show default printer
-p : show all printers
-a : show all printers that accept jobs
-o : show active print jobs
-----------------------------------------------------
lpr -o page-ranges=1-5 filename.pdf
Prints pages 1-5
-----------------------------------------------------
lpr -o number-up=4 document.pdf
Prints a standard portrait-formatted document 4 pages per sheet
-----------------------------------------------------
The following is an example of combining all of the options presented on this page. Assume that document.pdf is a 25 page portrait-formatted pdf file. The following command:
lpr -o sides=two-sided-long-edge -o number-up=6 -o page-ranges=2-3 document.pdf
will duplex print sheets 2 and 3 of the N-Up format, which will correspond to pages 7-18 of the original document, so that sheet 1 (pages 7-12) is on the front side of the printed page and sheet 2 (pages 13-18) is on the back side of the printed page.
-----------------------------------------------------
lpr -o number-up=4 -o number-up-layout=btlr document.pdf
Prints a standard landscape-formatted document 4 pages per sheet.
-----------------------------------------------------
lpr -PLaserjet4 blabla.pdf
Prints the PDF document blabla.pdf on the printer called Laserjet4
-----------------------------------------------------
lpr -Z duplex 123.dvi
Prints the DVI file 123.dvi with duplex
-----------------------------------------------------
lpr -Z 2up,duplex code.cc
Prints the sourcecode code.cc with 2 pages on both sides of the sheet
-----------------------------------------------------
lpr -Z 4up,duplex,ascii longtext.tex
Prints the source code of the TeX File longtext.tex with 4 on 1 page and on both sides of the sheet
-----------------------------------------------------
lpr -Z book longtext.tex
Prints the TeX File longtext.tex as a booklet
- HOME
~~~~~~~~~~~~~~~
- OpenBSD
- NetBSD
- FreeBSD
- Linux
- Solaris
- Windows
~~~~~~~~~~~~~~~
- Git
- Ansible
- Atlassian
- Network tools
- Qemu
- Virtualbox
- Vim
- Tmux
- Mutt
- STar
~~~~~~~~~~~~~~~
- MySQL
- PostgreSQL
- Postfix
- OpenSSL
- tcpdump
- SSH
~~~~~~~~~~~~~~~
- Packet Filter
- IP Filter
~~~~~~~~~~~~~~~
- Bash
- web-dev
- Hacking
- LINUX DAYS