Print a PDF on a printer without CUPS or other driver

Revision history
Tags: linux

I think CUPS is too much. I just want to print simple files from the command line. This is how it works for me with the printers I have been connecting to.

Depending on how your printer is connected, the target to which you pipe will differ

In the examples below I am using a network printer and connecting to it using the following information:


If you simply want to print plain text, you can pipe it straight through

$ echo "hello, world!" | nc -w 1 $PRINTER_IP $PRINTER_PORT

If you want to print a PDF, you most probably have to convert it to PostScript first. I use pdf2ps for this. Using - as a target filename will output to stdout.

$ pdf2ps ~/my-file.pdf - | nc -w 1 $PRINTER_IP $PRINTER_PORT

Using lp

If you want to use lp for printing, use the -h argument. Specifying - as input filename will make it read from stdin.

$ echo foobar | lp -h ${PRINTER_IP}:${PRINTER_PORT} -


If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).

Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.