如何從Linux命令行打印
來自Linux命令行的打印文檔很容易。您使用LP命令請求打印和LPQ查看隊列中哪些打印作業。但是,當您想在雙方打印或使用肖像模式時,事情會變得更加複雜。您可能想做的其他許多事情 - 例如打印多個文檔副本或取消打印作業。查看一些從Linux命令行打印文檔的選項!
顯示打印機設置
要從命令行查看打印機設置,請使用lpoptions命令。輸出看起來像這樣:
$ lpoptions copies=1 device-uri=dnssd://HP%20Color%20LaserJet%20CP2025dn%20(F47468)._pdl-datastream._tcp.local/ finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=1553023232 marker-colors=#000000,#00FFFF,#FF00FF,#FFFF00 marker-levels=18,62,62,63 marker-names='Black Cartridge HP CC530A,Cyan Cartridge HP CC531A,Magenta Cartridge HP CC533A,Yellow Cartridge HP CC532A' marker-types=toner,toner,toner,toner number-up=1 printer-commands=none printer-info='HP Color LaserJet CP2025dn (F47468)' printer-is-accepting-jobs=true printer-is-shared=true printer-is-temporary=false printer-location printer-make-and-model='HP Color LaserJet cp2025dn pcl3, hpcups 3.18.7' printer-state=3 printer-state-change-time=1553023232 printer-state-reasons=none printer-type=167964 printer-uri-supported=ipp://localhost/printers/Color-LaserJet-CP2025dn sides=one-sided
請注意列出了多少個設置。
筆記:在下面的輸出中,重新連接一些行以使此輸出更可讀。
$ lpoptions | tr " " 'n' copies=1 device-uri=dnssd://HP%20Color%20LaserJet%20CP2025dn%20(F47468)._pdl-datastream._tcp.local/ finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=1553023232 marker-colors=#000000,#00FFFF,#FF00FF,#FFFF00 marker-levels=18,62,62,63 marker-names='Black Cartridge HP CC530A, Cyan Cartridge HP CC531A, Magenta Cartridge HP CC533A, Yellow Cartridge HP CC532A' marker-types=toner,toner,toner,toner number-up=1 printer-commands=none printer-info='HP Color LaserJet CP2025dn (F47468)' printer-is-accepting-jobs=true printer-is-shared=true printer-is-temporary=false printer-location printer-make-and-model='HP Color LaserJet cp2025dn pcl3, hpcups 3.18.7' printer-state=3 printer-state-change-time=1553023232 printer-state-reasons=none printer-type=167964 printer-uri-supported=ipp://localhost/printers/Color-LaserJet-CP2025dn sides=one-sided
與-v選項,,,,這lpinfo命令將列出驅動程序和相關信息。
$ lpinfo -v network ipp network https network socket network beh direct hp network lpd file cups-brf:/ network ipps network http direct hpfax network dnssd://HP%20Color%20LaserJet%20CP2025dn%20(F47468)._pdl-datastream._tcp.local/ <== printer network socket://192.168.0.23 <== printer IP
這lpoptions命令將顯示默認打印機設置。使用-p指定可用打印機之一的選項。
$ lpoptions -p LaserJet
這LPSTAT -P命令顯示打印機的狀態和LPSTAT -P -D命令還列出了可用的打印機。
$ lpstat -p -d printer Color-LaserJet-CP2025dn is idle. enabled since Tue 19 Mar 2019 05:07:45 PM EDT system default destination: Color-LaserJet-CP2025dn
有用的命令
要在默認打印機上打印文檔,只需使用LP命令,然後是要打印的文件的名稱。如果文件名稱包含Whitespace(在Linux系統上非常罕見),請將名稱放入引號或開始鍵入文件名,然後按選項卡鍵單獨標記文件名(如下第二個示例中)。
$ lp "never leave home angry" $ lp never leave home angry
這LPQ命令顯示打印隊列。
$ lpq Color-LaserJet-CP2025dn is ready and printing Rank Owner Job File(s) Total Size active shs 234 agenda 2048 bytes
與-n選項,,,,這LP命令允許您指定要打印文檔的副本數量。
$ lp -n 11 agenda
要取消打印作業,您可以使用取消或者lprm。如果您不迅速採取行動,可以看到:
$ cancel 229 cancel: cancel-job failed: Job #229 is already completed - can't cancel.
雙工
要以雙面模式打印,您可以發行LP用邊選項,,,,因此,機器知道在紙的兩側要打印哪一側,哪個紙將翻轉。此設置與其他兩面打印相同。
$ lp -o sides=two-sided-long-edge Notes.pdf
如果您希望所有文檔以雙面模式打印,則可以使用lpoptions命令更改設置邊。
$ lpoptions -o sides=two-sided-short-edge
要返回單面打印,您將使用以下命令:
$ lpoptions -o sides=one-sided
以景觀模式打印
要在景觀模式下打印,您將使用與LP命令相等的選項。
$ lp -o landscape penguin.jpg
杯子
Linux操作系統上使用的打印系統是一種標準的開源打印系統,稱為杯子,縮寫普通的UNIX打印系統。杯子允許計算機充當打印服務器。