• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lpr Command Examples in Linux

by admin

The lpr command submits files for printing. Files supplied at the command-line are sent to the specified printer or to the print queue if the printer is busy. Without specifying the printer to use, the command will send the print job to the default printer, which you can configure with CUPS. The lpr command reads the print file from standard input if no files are supplied at the command-line.

Syntax

The syntax of the lpr command is:

# lpr [options] [file names]

lpr Command Options

The lpr command options are described in the following table.

Option Description
-E Force encryption when connecting to the server.
-P {destination} Send the print job to the destination printer specified.
-# {copies} Set the number of copies to print from 1 to 100.
-T {name} Set the job name.
-l Specify that the print file is already formatted and should be sent to the destination without being filtered.
-o {option} Set a job option, like printing in landscape mode, scaling the printed output, printing double-sided, etc. Job options vary depending on the printer.
-p Print the specified files with a shaded header that includes the date, time, job name, and page number.
-r Specify that the printed files should be deleted after printing.

lpr Command Examples

1. Print a file to the default printer:

# lpr path/to/file

2. Print 2 copies:

# lpr -# 2 path/to/file

3. Print to a named printer:

# lpr -P printer path/to/file

4. Print either a single page (e.g. 2) or a range of pages (e.g. 2–16):

# lpr -o page-ranges=2|2-16 path/to/file

5. Print double-sided either in portrait (long) or in landscape (short):

# lpr -o sides=two-sided-long-edge|two-sided-short-edge path/to/file

6. Set page size (more options may be available depending on setup):

# lpr -o media=a4|letter|legal path/to/file

7. Print multiple pages per sheet:

# lpr -o number-up=2|4|6|9|16 path/to/file

8. Print a manpage by piping to lpr’s standard input:

# man -t 5 printcap | lpr

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  2. How to configure NTP to fall back to local system clock source in CentOS/RHEL
  3. getopt Command Examples in Linux
  4. setenforce Command Examples in Linux
  5. pacstrap Command Examples in Linux
  6. jpegtran: command not found
  7. xz: command not found
  8. Understanding How an Email System Works
  9. sfill: command not found
  10. ldconfig Command Options

You May Also Like

Primary Sidebar

Recent Posts

  • “glab pipeline” Command Examples
  • “glab mr” Command Examples
  • “glab mr merge” Command Examples
  • “glab mr” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright