Linux Commands Examples

A great documentation place for Linux commands


print files

see also : cancel - lp - lpadmin - lpoptions - lpq - lprm - lpstat


lpr [ -E ] [ -H server[:port] ] [ -U username ] [ -P destination[/instance] ] [ -# num-copies [ -h ] [ -l ] [ -m ] [ -o option[=value] ] [ -p] [ -q ] [ -r ] [ -C/J/T title ] [ file(s) ]

add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!


lpr $*

Printing from the command line with LibreOffice, lpr commands?

You can't pass lpr command line options to libreoffice. Two possible solutions are:

  1. One step solution (the best solution in my opinion): use unoconv outputting a PDF to stdout piped to lpr:

    $ unoconv --stdout filename.doc | lpr -U username -P the_printer_name
  2. Three step solution (if you don't want / can't use unoconv): use libreoffice --print-to-file to a temporary file + lpr of the file + delete the temporary file (unfortunatelly libreoffice still doesn't support printing to stdout):

    $ libreoffice --headless --print-to-file --printer-name the_printer_name --outdir /tmp filename.doc
    $ lpr -U username /tmp/ -P the_printer_name
    $ rm /tmp/
lpr -Plp evtmlib.c
lpr -Plp evtmlib.h
lpr -Plp timerlib.h
lpr -Plp timerlib.c
lpr -Plp tcplib.h
lpr -Plp tcplib.c
lpr -Plp cli.c
lpr -Plp ser.c
lpr -Plp makefile

Linux: how to list printer names acceptable for use with lpr?

$ lpstat -p -d

From the CUPS manual.


Cups line printer skip page after printing one line

The CUPS printer server considers everything that you send it as a separate printer job. This means, your line containing "Hi" is a printer job. By default, different printer jobs go to different pages; this explains what you are now getting.

Now, 30 years ago when all printers were like your Epson 9pin, things were different. Printer managers like CUPS were seldom used. It was very common to send data to the printer one line at a time, like you do with your echo, and it was natural for the printer to wait for the next line, without going to the next page. This is how we used to print stuff. If you want to do that now, you'll have to print using "RAW" mode, practically bypassing the printer job management that CUPS performs. You'll also need to suppress the "form feed" that CUPS by default sends in between printer jobs, which causes the page change; you'll need to print a final "form feed" yourself.

I suggest that you take a look here, you may find your answer already waiting.


lpr -o page-ranges=1 is still printing all three pages

Appears it would be: lp -p 1

(plus whatever else you'll need to pass to lp to get it to print what you want to print).


lpr submits files for printing. Files named on the command line are sent to the named printer (or the default destination if no destination is specified). If no files are listed on the command-line, lpr reads the print file from the standard input.


The following options are recognized by lpr:


Forces encryption when connecting to the server.

-H server[:port]

Specifies an alternate server.

-C "name"
-J "name"
-T "name"

Sets the job name.

-P destination[/instance]

Prints files to the named printer.

-U username

Specifies an alternate username.

-# copies

Sets the number of copies to print from 1 to 100.


Disables banner printing. This option is equivalent to "-o job-sheets=none".


Specifies that the print file is already formatted for the destination and should be sent without filtering. This option is equivalent to "-o raw".


Send an email on job completion.

-o option[=value]

Sets a job option.


Specifies that the print file should be formatted with a shaded header with the date, time, job name, and page number. This option is equivalent to "-o prettyprint" and is only useful when printing text files.


Hold job for printing.


Specifies that the named print files should be deleted after printing them.


The "c", "d", "f", "g", "i", "n", "t", "v", and "w" options are not supported by CUPS and produce a warning message if used.


Copyright 2007-2013 by Apple Inc.

the default destination

CUPS provides many ways to set the default destination. The "LPDEST" and "PRINTER" environment variables are consulted first. If neither are set, the current default set using the lpoptions(1) command is used, followed by the default set using the lpadmin(8) command.

see also

cancel , lp , lpadmin , lpoptions , lpq , lprm , lpstat ,

How can this site be more helpful to YOU ?

give  feedback