-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path108-4-Manage-printers-and-printing
176 lines (141 loc) · 7.31 KB
/
108-4-Manage-printers-and-printing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
####################################################################
108.4 Manage printers and printing
####################################################################
Candidates should be able to manage print queues and user print jobs using CUPS and the LPD compatibility interface.
Key Knowledge Areas
& Basic CUPS configuration (for local and remote printers).
& Manage user print queues.
& Troubleshoot general printing problems.
& Add and remove jobs from configured printer queues.
################################
Terms and Utilities
################################
& CUPS configuration files, tools and utilities
& /etc/cups/
& lpd legacy interface (lpr, lprm, lpq)
################################
CUPS
################################
Most Linux distros use CUPS for printing. CUPS stands for Common Unix Printing System. There are different interfaces for CUPS link command line tools, web based interface and GUIs. CUPS is designed to simplify the printing on various printers from different manufactures.
################################
CUPS web interface
################################
The general way to access the CUPS configuration and info page is going to the servers IP on port 631 from a browser. That will be localhost:631 or 127.0.0.1:631 from your browser.
Important parts on this webpage are:
|Jobs tab|to check the jobs the CUPS is handling|
|Administration|For adding printers, managing jobs and configuring the CUPS server|
|Printers|Show the printers|
as soon as you push the Add Printer button, you will need to give CUPS admin user password
Suggested Activity: Visit your CUPS web interface and add a printer
Good news is that the CUPS has most of the common printer drivers installed. You just need to choose the printer from the dropdown menu.
################################
configuration files
################################
As any other linux program, CUPS saves its configuration at /etc directory.
# ls /etc/cups
cups-browsed.conf interfaces raw.types subscriptions.conf
cupsd.conf ppd snmp.conf subscriptions.conf.O
cups-files.conf raw.convs ssl
One important file is cupsd.conf. Have a look at it; it is very easy to understand. For example the Listen localhost:631 line tells the CUPS to listen on localhost port 631.
All the printer data is saved at /etc/cups/printers.conf. The web interface or any other GUI is actually editing this file.
# Printer configuration file for CUPS v2.1.0
# Written by cupsd
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
<DefaultPrinter Apple-Dot-Matrix>
UUID urn:uuid:0f6c2f2b-6338-388a-76de-09f2ef1994d5
Info Apple Dot Matrix
Location Fake Location
MakeModel Apple Dot Matrix Foomatic/appledmp (recommended)
DeviceURI ipp://fakeprinter/
State Idle
StateTime 1453402271
ConfigTime 1453402271
Type 8433668
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job
</DefaultPrinter>
################################
legacy tools
################################
Just like the MTA programs, CUPS support all the legacy command line programs too.
command usage
lpr print a file
lpq show print queue/jobs
lprm rm/remove a file from priner queue
lpc printer control / troubleshooting program
################################
lpq
################################
The q is for queue therefor lpq shows the printer queue and is used when you want to see the jobs. If you use the -a switch, the lpq will show the jobs of all printers. Alternatively you can use the -P switch to show the jobs of a specific printer. So the following command will show the jobs of a printer called Apple-Dot-Matrix:
# lpq -PApple-Dot-Matrix
Apple-Dot-Matrix is ready and printing
Rank Owner Job File(s) Total Size
active unknown 1 unknown 7168 bytes
1st unknown 2 unknown 2048 bytes
It is strange but there should not be ANY space between -P and the printers name
################################
lpr
################################
This command is used to send a job to a printer. Again the printer is specified by -P.
$ lpr -PApple-Dot-Matrix for_print.txt
lpq
Apple-Dot-Matrix is ready and printing
Rank Owner Job File(s) Total Size
active mojtaba 1 Untitled Document 1 7168 bytes
1st mojtaba 2 Untitled1 2048 bytes
2nd mojtaba 3 for_print.txt 1024 bytes
If no printer is specified, the default printer will be used
################################
lprm
################################
The rm is for remove so the lprm will remove jobs from the queue. You need to provide the Job ID to this command.
$ lpq
Apple-Dot-Matrix is ready and printing
Rank Owner Job File(s) Total Size
active mojtaba 1 Untitled Document 1 7168 bytes
1st mojtaba 2 Untitled1 2048 bytes
2nd mojtaba 3 for_print.txt 1024 bytes
mojtaba@funlife:/tmp$ lprm 2
mojtaba@funlife:/tmp$ lpq
Apple-Dot-Matrix is ready and printing
Rank Owner Job File(s) Total Size
active mojtaba 1 Untitled Document 1 7168 bytes
1st mojtaba 3 for_print.txt 1024 bytes
Only root can remove other peoples print jobs
If you need to remove ALL the jobs of a specific printer, you can go with -Pprinter_name -. Yes! that is only one dash (-) after the printer name; that's why this is called a legacy command.
the lprm - will remove all the print jobs
################################
lpc
################################
Here, the c is for control. lpc lets you check the status (via lpc status) and troubleshoot your printers.
$ lpc status
Apple-Dot-Matrix:
printer is on device 'ipp' speed -1
queuing is enabled
printing is enabled
2 entries
daemon present
Here,
& queuing is enabled tell us that the queue can accept new print jobs. If the queue is disabled, you can not even send new jobs to the printer.
& printing is enabled means that the printer is actually can print on the paper. This will be on the disable state if the printer is out of ink or paper or experiencing a paper jam.
If you are having problems with your printer or need to prevent it from accepting new jobs or let it accept jobs but not print, these four commands will let you achieve your needs:
command usage
cupsaccept tells the printer queue to accept new jobs
cupsreject tells the printer to reject any new job
cupsenable enables the actual/physical printing of the jobs
cupsdisable disables the physical printing of the jobs
In all cases you have to provide the printer name of the printer. it is also possible to provide a reason using -r switch.
$ cupsdisable Apple-Dot-Matrix -r "need more paper"
$ lpc status
Apple-Dot-Matrix:
printer is on device 'ipp' speed -1
queuing is enabled
printing is disabled
2 entries
daemon present