https://www.networkworld.com/article/3373502/printing-from-the-linux-command-line.html
The lpstat -p command displays the status of a printer while lpstat -p -d also lists available printers.
With the -n option, the lp command allows you to specify the number of copies of a printout you want.
To cancel a print job, you can use the cancel or lprm command. If you don't act quickly, you might see this:
To print in landscape mode, you would use the landscape option with the lp command.
https://www.cups.org/doc/man-lp.html
- -o media=size
- Sets the page size to size. Most printers support at least the size names "a4", "letter", and "legal".
- -o number-up={2|4|6|9|16}
- Prints 2, 4, 6, 9, or 16 document (input) pages on each output page.
- -o orientation-requested=4
- Prints the job in landscape (rotated 90 degrees counter-clockwise).
- -o orientation-requested=5
- Prints the job in landscape (rotated 90 degrees clockwise).
- -o orientation-requested=6
- Prints the job in reverse portrait (rotated 180 degrees).
- -o print-quality=3
- -o print-quality=4
- -o print-quality=5
- Specifies the output quality - draft (3), normal (4), or best (5).
- -o sides=one-sided
- Prints on one side of the paper.
- -o sides=two-sided-long-edge
- Prints on both sides of the paper for portrait output.
- -o sides=two-sided-short-edge
- Prints on both sides of the paper for landscape output.
- -t "name"
- Sets the job name.
- -H hh:mm
- -H hold
- -H immediate
- -H restart
- -H resume
- Specifies when the job should be printed. A value of immediate will print the file immediately, a value of hold will hold the job indefinitely, and a UTC time value (HH:MM) will hold the job until the specified UTC (not local) time. Use a value of resume with the -i option to resume a held job. Use a value of restart with the -i option to restart a completed job.
To print from command line we need, first of all, to know which printers are available for our system and how are named. To do that, we use following command:
$ lpstat -a
https://www.computerhope.com/unix/ulpstat.htm
-a [printer(s)] | Shows the accepting state of printer queues. If no printers are specified then all printers are listed. |
-l | Shows a long listing of printers, classes, or jobs. |
lp -d <printername> -o ColorModel=CMYK <filename.extension>
Set your printer default to color
sudo lpoptions -p the_printer -o <name=value>
Example: To make banana-color print in color by default on your computer:
sudo lpoptions -p the_printer -o ColorModel=CMYK
To change back to black and white:
sudo lpoptions -p the_printer -o ColorModel=Gray
Note Option commands vary by printer and model. To see available options for a specific printer:
lpoptions -p printername -l
Maybe you are looking for
lpoptions
?
Use
lpoptions -l
in order to know what's the name for your printer.
You can play it like thi (example with an HP Photosmart) :
lp -o scaling=//100// -oColorModel=KGray image.jpg
lpoptions -d the_printer -l | grep -i color
https://www.math.wisc.edu/wiki/index.php/Examples
lp -d P file.pdf (send file to printer P - e.g. P=5) lp -o sides=one-sided file.pdf (to each page on one side only) lp -o ColorModel=color file.pdf (print in color) lp -o sides=two-sided-short-edge file.pdf (duplex along short edge instead of long) lp -o page-ranges=1 (print just page 1) lp -o page-ranges=1-4,7,9-12
You can combine these commands, for example:
lp -o sides=two-sided-short-edge -o ColorModel=color file.pdf (useful for printing tri-fold brochures)
lpoptions
Use the lpoptions command to save these options for later use. For example, you might want to do color printing to the printer on another floor, reserving the printer on your own floor for the normal grayscale prints. This command will ensure that anything you send to the 5th floor printer will be printed in color:
lpoptions -d 5 ColorModel=color
your lpoptions commands are saved in the file ~/.cups/lpoptions. Typing lpoptions by itself will show you what your current printer setup is.
Checking the queue and cancelling jobs
Use the lpstat command to check the status of a queue and cancel to cancel jobs
lpstat -d5 -t (checks jobs on queue 5) cancel 5-241 (deletes job 5-241 from queue 5)
You can also cancel jobs using the printer icon which will appear in the top right hand corner of your screen when you start your job. To do this, open the printer icon, right click on your job and select cancel (not delete).
lpoptions -d the_printer -o ColorModel=color
https://stackoverflow.com/questions/33977512/how-to-send-send-cups-a-print-only-in-black-ink-command
- not work
The setting to print color as grey (from the ppd) is valid an is processed.
HPPJLColorAsGray/Print Color as Gray: False HighQuality * BlackInkOnly
But the settings from the actual printout "overwrite" the default values (what makes sense to me) and in case color is in an document an this is printed with default values -- the colour ink is used. This behaviour can be controlled in the print dialogue generally. E.g. in libreoffice you can use an option "print text in black ink" this would result in real black text (not mixed as black from colors).
In LaTeX you can use
\usepackage[monochrome]{xcolor}
to force all text to black an so the use of the black ink.
Im my case I wanted to directly print to the print queue even though the default was set in the ppd to use BlackInkOnly it was not the case. After I added this option additionally as parameter to my print command it worked as I want it to be: color is printed in gray and only the black ink is used.
lpr -P<printqueue> -o HPPJLColorAsGray=BlackInkOnly ...
https://docs.oracle.com/cd/E19082-01/819-7761/gfjex/index.html
- Set the system's default printer.
# lpadmin -d [printer-name]
- Check the system's default printer.
# lpstat -d
# lpadmin -d [printer-name] |
-d printer-name | Name of the printer you are assigning as the system's default printer. If you don't specify printer-name, the system is set up with no default printer. |
https://alvinalexander.com/unix/edu/examples/lp.shtml
This command prints the ".profile" file to the printer named "Sales". The -d option specifies the destination.
lp -dSales file1 file2 file3
This command prints the three files "file1", "file2", and "file3" to the printer named "Sales".
lp -i Sales-101 -H hold
This command places the print request Sales-101 on hold.
lp -i Sales-101 -H resume
This command resumes the print request Sales-101. The print request starts printing from page one unless you instruct it otherwise.
lp -i Sales-101 -H resume -P 4-
This command resumes the print request Sales-101, starting with page 4 of the print job. Note that the final hyphen (following the "4") is required.
The "lp" command can also be used as part of a pipeline. For instance, the following command will print the output of the "ps -ef" command to the default printer:
ps -ef | lphttps://www.jdyoung.com/2018/01/12/youre-going-print-print-efficiently/
Save Ink– Use grayscale as the default print setting and only switch to full color on the final version or for client-facing documents.
Fonts Matter– In 2014, a teenager discovered the government could save more than $200 million a year by using Garamond instead of Times New Roman when printing documents. You probably won’t save that much, but using thinner and lighter fonts like Garamond or Evergreen can save on ink.
Start Selectively Printing
Pull, not push
Many enterprise printing systems now offer a 'pull-printing' option. Instead of sitting at your desk and sending documents to a remote printer, pull-printing requires the user to manually enter a security code on the printer itself. This provides greater security, reduces uncollected paper left in the printer - and might even make people think twice before pushing the 'Print' button.