Learn Ways to Use Linux lp Command With Examples

The 'lp' command is used to print files on Unix and Linux systems. The name 'lp' stands for 'line printer'. Normal users are allowed to have direct access to the printer. Users have to spool a job in a print queue. Spooling ensures the orderly printing of jobs.

lp command is very useful in printing files when GUI is not installed on Linux. It serves as a front-end command that calls the lpr command with appropriate options.

Change paper size using command prompt

It is very easy to change paper size in GUI environment. But how do you change paper size with command prompt?

The lp command prints to A4 paper size by default. However, if you want to print in a different paper size using the command prompt such as A3 or A5 then type as given below. Supported printer sizes are: "a4", "letter", and "legal".

$ lp -o media=A3 /path

Where, -o media=size : Sets the page size to size.
Print a double-sided legal document to a printer called "printer1":

$ lp -d printer1 -o media=legal -o sides=two-sided-long-edge /path

Print an image using a printer called "printer2":

$ lp -d printer2 -o scaling=200 filename

lp command examples

The command given below prints /etc/passwd file to the default printer destination:

$lp /etc/passwd

Print the “.profile” file to the printer named “Sales”. The -d option specifies the destination.

$lp -dSales .profile

Simultaneous printing of more than one files:

$lp -dSales file1 file2 file3

This command places the print request Sales-101 on hold:

$lp -i Sales-101 -H hold

This command resumes the print request Sales-101:

$lp -i Sales-101 -H resume

The command given below resumes the print request Sales-101 starting with page 4:

$lp -i Sales-101 -H resume -P 4-

Use of pipeline with lp command. The command given below will print the output of the “ps -ef” command to the default printer:

$ps -ef | lp

To display the names of the printers that are connected to your system, use the lpc status command:

$lpc status

printer is on device 'parallel' speed -1
queuing is enabled
printing is enabled
no entries
daemon present

I hope these Linux lp command examples were helpful for you.

Bobbin Zachariah 8:09 pm

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author's All Posts
Like to become part of Linoxide Team and contribute tips? Contact us here.


Your email address will not be published. Required fields are marked *

All comments are subject to moderation.