Cách in từ dòng lệnh Linux

In tài liệu từ dòng lệnh Linux rất dễ dàng. Bạn sử dụng lệnh lp để yêu cầu in và lpq để xem nhiệm vụ in nào trong hàng đợi. Nhưng mọi thứ trở nên phức tạp hơn một chút khi bạn muốn in hai mặt hoặc sử dụng chế độ dọc (portrait). Và còn rất nhiều điều khác bạn có thể muốn làm - chẳng hạn như in nhiều bản sao của tài liệu hoặc hủy công việc in. Hãy xem một số tùy chọn để in tài liệu từ dòng lệnh Linux nhé!

Hiển thị cài đặt máy in

Để xem cài đặt máy in từ dòng lệnh, hãy sử dụng lệnh lpoptions. Đầu ra sẽ trông giống như sau:

$ 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

Lưu ý xem có bao nhiêu cài đặt được liệt kê.

GHI CHÚ: Trong đầu ra bên dưới, một số dòng đã được kết nối lại để làm cho đầu ra này dễ đọc hơn.

$ 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ới tùy chọn -v, lệnh lpinfo sẽ liệt kê các driver và thông tin liên quan.

$ 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

Lệnh lpoptions sẽ hiển thị các cài đặt của máy in mặc định. Sử dụng tùy chọn -p để chỉ định một trong số máy in có sẵn.

$ lpoptions -p LaserJet

Lệnh lpstat -p hiển thị trạng thái của máy in còn lệnh lpstat -p -d cũng liệt kê các máy in có sẵn.

$ 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

Các lệnh hữu ích

Để in tài liệu trên máy in mặc định, chỉ cần sử dụng lệnh lp theo sau là tên của file bạn muốn in. Nếu tên file bao gồm khoảng trắng (rất hiếm trên các hệ thống Linux), hãy đặt tên trong dấu ngoặc kép hoặc bắt đầu nhập tên file và nhấn phím Tab để đánh dấu riêng phần tên file (như trong ví dụ thứ hai bên dưới).

$ lp "never leave home angry"
$ lp never\ leave\ home\ angry

Lệnh lpq hiển thị hàng đợi in.

$ lpq
Color-LaserJet-CP2025dn is ready and printing
Rank Owner Job File(s) Total Size
active shs 234 agenda 2048 bytes

Với tùy chọn -n, lệnh lp cho phép bạn chỉ định số lượng bản sao của tài liệu muốn in.

$ lp -n 11 agenda

Để hủy lệnh in, bạn có thể sử dụng lệnh cancel hoặc lprm. Nếu không hành động nhanh, bạn có thể thấy điều này:

$ cancel 229
cancel: cancel-job failed: Job #229 is already completed - can't cancel.

In hai mặt

Để in ở chế độ hai mặt, bạn có thể đưa ra lệnh lp với tùy chọn sides, để máy biết yêu cầu in trên cả hai mặt giấy và giấy sẽ lật theo cạnh nào. Cài đặt này cũng giống như việc in 2 mặt thông thường khác.

$ lp -o sides=two-sided-long-edge Notes.pdf

Nếu bạn muốn tất cả các tài liệu của mình được in ở chế độ hai mặt, bạn có thể thay đổi cài đặt lp, bằng cách sử dụng lệnh lpoptions để thay đổi cài đặt cho sides.

$ lpoptions -o sides=two-sided-short-edge

Để trở lại in một mặt, bạn sẽ sử dụng lệnh sau:

$ lpoptions -o sides=one-sided

In ở chế độ ngang

Để in ở chế độ ngang, bạn sẽ sử dụng tùy chọn ngang với lệnh lp.

$ lp -o landscape penguin.jpg

CUPS

Hệ thống in được sử dụng trên các hệ điều hành Linux là hệ thống in mã nguồn mở dựa trên tiêu chuẩn có tên CUPS, viết tắt của Common Unix Printing System. CUPS cho phép một máy tính hoạt động như một máy chủ in.

Thứ Ba, 23/04/2019 15:30
52 👨 565
0 Bình luận
Sắp xếp theo
    ❖ Linux