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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. 7 Useful Find Command Examples to Locate files to remove when a filesystem is full
  2. How to Restrict Active Directory Users and Groups to Login to CentOS/RHEL 7 Client
  3. How to delete a non-root use with UID 0 in Linux
  4. conntrack: command not found
  5. ipcalc: command not found
  6. How to Delete ASM Disk on Multipath Device in CentOS/RHEL
  7. loginctl Command Examples in Linux
  8. e2image: command not found
  9. How to Disable rpc.quotad Service in CentOS/RHEL 6 and 7
  10. How to Schedule Jobs with ‘at’ command under Linux

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright