Printing from the Terminal

I obtained this systemd “cheatsheet” a while back: it’s a pdf file. I was attempting to print it to no avail. I would select print after opening the file, but the printer did not acknowledge at all. In the past when this occurred with pdf files, I deleted the printer driver and reinstalled it with success.

Not wanting to do that again, I re-discovered the gui for the CUPS driver, localhost:631, which gives the Terminal commands and printed the file directly to the printer…Much simpler! Just enter the address localhost:631 into your browser:

and there it is.

i have looked around at the in-browser printer functionality available at localhost:631 a few times, but never realized there were command line printing instructions. that is cool :mage:

do you mind sharing the command you used just in case it might help someone else who sees this in the future, but is uncertain of what exactly to type in?

i first learned about lpr from an outdated but still useful linux command lines tips and tricks book i picked up at the library. the particular trick i was trying to learn was printing a man page since sometimes reading them in hand helps me remember better than reading them on the screen.

the book suggested man -t lpr | lpr (where -t formats the page for printing before piping if i am reading the man man page correctly), but i apparently didn’t have a default printer set. lpstat -p got me the name of my printer and i was able to use man -t lpr | lpr -P name_of_default_printer to have a copy in hand.

lp filename

I was not sure the file would print in the landscape mode, but it did. If you read down to “Specifying Printer Options,” you are able to enter most parameters, but in this case the file printed out perfectly with just the above.