The lp command is used to print files on Unix and Linux systems. The name "lp" stands for "line printer". As with most Unix commands there are a fairly large number of options available to enable flexible printing capabilities.
Let's look at some lp printing commands examples.
Linux lp printing command examples
This command prints the "/etc/passwd" file to the default printer. If you do not use the "-d" option, the file is printed to the default printer destination.
lp -dSales .profile
This command prints the ".profile" file to the printer named "Sales". The -d option specifies the destination.
lp -dSales file1 file2 file3
This command prints the three files "file1", "file2", and "file3" to the printer named "Sales".
lp -i Sales-101 -H hold
This command places the print request Sales-101 on hold.
lp -i Sales-101 -H resume
This command resumes the print request Sales-101. The print request starts printing from page one unless you instruct it otherwise.
lp -i Sales-101 -H resume -P 4-
This command resumes the print request Sales-101, starting with page 4 of the print job. Note that the final hyphen (following the "4") is required.
The "lp" command can also be used as part of a pipeline. For instance, the following command will print the output of the "ps -ef" command to the default printer:
ps -ef | lp
Print the output of the "ps -ef" command to the default printer.
Linux lp printing command examples - Summary
I hope these Linux lp command examples have been helpful. (I also hope they're up to date; I don't have a Linux system to test these printing commands on currently, and I've just ported this article over from an old portion of my website.)