The lp
command is used to print files or modify queued print jobs in Linux. It is a command-line tool that is used to send print jobs to printers or print servers.
Overview
The lp
command is used to print files and manage print jobs. It is used to send print jobs to printers or print servers. The lp
command can be used to print files in various formats such as text, PostScript, PDF, and image files.
Syntax
The syntax of the lp
command is as follows:
lp [options] [filename]
Examples
Here are some examples of how to use the lp
command:
- Print a file:
lp filename.txt
- Print a file with multiple copies:
lp -n 3 filename.txt
- Print a file in landscape mode:
lp -o landscape filename.txt
- Print a file in duplex mode:
lp -o sides=two-sided-long-edge filename.txt
- Print a file to a specific printer:
lp -d printername filename.txt
- Cancel a print job:
cancel jobnumber
Specific use cases
The lp
command is commonly used in the following scenarios:
- Printing text files
- Printing PDF files
- Printing images
- Printing from the command line
- Printing from scripts
Options
Here is a list of available options for the lp
command:
Option | Description |
---|---|
-d printername |
Specify the printer to use |
-n copies |
Specify the number of copies to print |
-o option |
Specify print options |
-q priority |
Set the priority of the print job |
-s |
Print silently |
-U username |
Specify the username of the person who submitted the print job |
-P |
Show the status of print jobs |
-a |
Add a print job to the queue |
-r |
Remove a print job from the queue |
-t |
Move a print job to the top of the queue |
-i |
Print the job ID |
-H |
Print the hostname |
-M |
Print the class name |
-S |
Print the job size |
-T |
Print the job time |
-u |
Print the username |
Troubleshooting tips
Here are some troubleshooting tips for the lp
command:
- If the printer is not working, check the printer status using the
lpstat
command. - If the printer is not responding, check the printer connection and make sure it is turned on.
- If the print job is stuck in the queue, try cancelling the job and resubmitting it.
- If the print job is not printing correctly, check the printer configuration and make sure it is set up correctly.
Notes
- The
lp
command is available on most Linux distributions. - The
lp
command can be used to print to both local and network printers. - The
lp
command can be used to manage print jobs on a print server.