LPI Linux Certification in a Nutshell (57 page)

Read LPI Linux Certification in a Nutshell Online

Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger

Tags: #Reference:Computers

BOOK: LPI Linux Certification in a Nutshell
8.34Mb size Format: txt, pdf, ePub
Name

lp

Syntax
lp  [  -E ] [ -U
username
] [ -c ] [ -d
destination
[/
instance
] ]
[ -h
hostname
[:
port
] ] [ -m ]
[ -n
num-copies
] [ -o
option
[=
value
] ] [ -q
priority
] [ -s ] [ -t
title
]
[ -H
handling
] [ -P
page-list
] [ -- ] [
file(s)
]
Description

lp
submits files for printing
or alters a pending job.

Options
--

Prints from standard input.

-d
destination

Prints files to the named printer.

-o
"
name
=
value
[
name
=
value
...]”

Sets one or more job options.

Example 1

Print a double-sided legal document to a printer called
“foo”:

$
lp -d foo -o media=legal -o sides=two-sided-long-edge filename
Example 2

Print an image across four pages:

$
lp -d bar -o scaling=200 filename
Example 3

Print a text file with 12 characters per inch, 8 lines per
inch, and a 1-inch left margin:

lp -d bar -o cpi=12 -o lpi=8 -o page-left=72 filename
Name

cancel

Syntax
cancel [ -E ] [ -U
username
] [ -a ] [ -h
hostname
[:
port
] ] [ -u
username
] [
id
]
[
destination
] [
destination-id
]
Description

cancel
removes the specified
print jobs from the queue.

Options
-a

Cancels all jobs on the named destination, or all jobs
on all destinations if no destination is provided.

Name

lpstat

Syntax
lpstat [ -E ] [ -U
username
] [ -h
hostname
[:
port
] ] [ -l ] [ -W
which-jobs
]
[ -a [
destination(s)
] ] [ -c [
class(es)
] ] [ -d ]
[ -o [
destination(s)
] ]
[ -p [
printer(s)
] ] [ -r ] [ -R ] [ -s ] [ -t ] [ -u [
user(s)
] ]
[ -v [
printer(s)
] ]
Description

lpstat
displays status
information about the current classes, jobs, and printers. When
run with no arguments, it lists jobs queued by the current
user.

Options
-a
[
printer(s)
]

Shows the accepting state of printer queues. If no
printers are specified, shows all printers.

-t

Shows all status information. This option is very
useful for troubleshooting.

Name

lpadmin

Syntax
lpadmin [ -E ] [-U
username
] [ -h
server
[:
port
] ] -d
destination
lpadmin [ -E ] [-U
username
] [ -h
server
[:
port
] ] -p
printer option(s)
lpadmin [ -E ] [-U
username
] [ -h
server
[:
port
] ] -x
destination
Description

lpadmin
configures printer and
class queues provided by CUPS. It can also be used to set the
server default printer or class.

Options
-m model

Sets a standard System V interface script or PPD file
from the model directory.

-v
device-uri

Sets the device URI attribute of the printer queue. If
device-uri
is a filename, it is
automatically converted to the form
file:///
file
/
name
.
Use the
lpinfo
(8) command for a list of
supported device URIs and schemes.

-E

Enables the printer and accepts jobs; this is the same
as running the
accept
and
cupsenable
programs for a specific
printer.

Name

lpq

Syntax
lpq [
options
] [
users
] [
job#s
]
Description

Query a print queue. If numeric
job#s
are included, only those jobs are
listed. If
users
are listed, only jobs
submitted by those users are listed.

Options
-l

Long output format. This option results in a multiline
display for each print job.

-P
name

This specifies the print queue
name
. In the absence of
-P
, the default printer is
queried.

Example 1

Examine active jobs:

$
lpq
lp is ready and printing
Rank Owner Job Files Total Size
active root 193 filter 9443 bytes
1st root 194 resume.txt 11024 bytes
2nd root 196 (standard input) 18998 bytes

Here,
filter
is currently being
printed.
resume.txt
is up next, followed by
the 18,998 bytes of data piped into
lpr
’s
standard input.

Example 2

Examine those same jobs using the long format:

$
lpq -l
lp is ready and printing
root: active [job 193AsJRzIt]
filter 9443 bytes
root: 1st [job 194AMj9lo9]
resume.txt 11024 bytes
root: 2nd [job 196A6rUGu5]
(standard input) 18998 bytes
Example 3

Examine queue
lp
, which
turns out to be empty:

$
lpq -Plp
no entries
Example 4

Examine jobs owned by
bsmith
:

$
lpq bsmith
Rank Owner Job Files Total Size
7th bsmith 202 .bash_history 1263 bytes
9th bsmith 204 .bash_profile 5676 bytes

Using the job numbers reported by
lpq
,
any user may remove her own print jobs from the queue, or the
superuser may remove any job.

Name

lprm

Syntax
lprm [
-Pname
] [
users
] [
job#s
]
lprm -ly
Description

Remove jobs from a print queue. In the first form,
remove jobs from queue
name
or from the
default queue if
-P
is omitted. If
users
or
jobs
are specified, only those jobs
will be removed. In the second form, all of a normal user’s jobs
will be omitted; for the superuser, the queue will be
emptied.

Example 1

As a normal user, remove all of your print jobs:

$
lprm -
Example 2

As the superuser, remove all jobs from queue
ps
:

#
lprm -Pps -

You may occasionally be surprised to see a
no entries
response from
lpq
, despite observing that the printer
is dutifully printing a document. In such cases, the spool has
probably been emptied into the printer’s buffer memory, and the
result is that the job is no longer under the control of the
printing system. To kill such jobs, you need to use the printer’s
controls to stop and delete the job from memory.

Name

lpr

Syntax
lpr [
options
] [
files
]
Description

Send
files
or standard
input to a print queue. A copy of the input source is placed in
the spool directory under
/var/spool/lpr
until the print job is complete.

Frequently used options
-#
number

Send
number
copies of the
print job to the printer.

-s

Instead of copying a file to the print spooling area,
make a symbolic link to the file, thereby eliminating
transfer time and storage requirements in
/var/spool/lpr
. This can relieve load
on the daemon’s system for very large files.

-P
name

Specify the print queue
name
. In the absence of
-P
, the default printer is
queried.

Example 1

Print the file
/etc/fstab
on the
default print queue:

#
lpr /etc/fstab
Example 2

Print a manpage by piping to
lpr
’s
standard input:

#
man -t 5 printcap | lpr
Example 3

Disable a print queue:

#
lpc disable lp

Then, attempt to print three copies of a file to the
disabled queue as superuser:

#
lpr -#3 /etc/fstab

This succeeds, despite the disabled printer queue. Now try
as a regular user:

$
lpr -#3 ~/resume.txt
lpr: Printer queue is disabled

As expected, normal users can’t print to the disabled
queue.

On the Exam

You must be familiar with
lp
and its use with both
files and standard input. Also remember that
lp
doesn’t send data to the printer but to
the printer daemon (
cupsd
on Linux), which
handles sending it to the printer backend and then to the
printer.

Troubleshooting General Printing Problems

Logfiles are the first, and sometimes the best, guide to
solving problems with printing. Many people still make the basic mistake
of forgetting to check logfiles. These files are rotated, so that you can
find recent events in the main file and older events in gzipped backup
files. If you need even more detail, change the
LogLevel
line in
/etc/cups/cupsd.conf
to the value
debug
. It will dump loads of extra
information into the logfiles for subsequent print operations.

You should also know about the
cups-config
command, which has some options that show you information about the
current state of the system.

The Error Logfile

Recent errors and related information can be found in
/var/log/cups/error_log
. This file
lists messages from the scheduler, which includes both errors and
warnings. You can view detailed and real-time information about data
transferring, filtering, etc. Sample messages generated by one typical
job are:

I [16/Nov/2009:11:19:07 +0100] [Job 102] Adding start banner page "none".
I [16/Nov/2009:11:19:07 +0100] [Job 102] Adding end banner page "none".
I [16/Nov/2009:11:19:07 +0100] [Job 102] File of type application/postscript
queued by "brunop".
I [16/Nov/2009:11:19:07 +0100] [Job 102] Queued on "PDF" by "brunop".
I [16/Nov/2009:11:19:07 +0100] [Job 102] Started filter
/usr/libexec/cups/filter/pstops (PID 18223)
I [16/Nov/2009:11:19:07 +0100] [Job 102] Started backend
/usr/libexec/cups/backend/cups-pdf (PID 18224)
I [16/Nov/2009:11:19:07 +0100] [Job 102] Completed successfully.
I [16/Nov/2009:11:20:17 +0100] [Job ???] Request file type is
application/postscript.
I [16/Nov/2009:11:20:17 +0100] [Job 103] Adding start banner page "none".
I [16/Nov/2009:11:20:17 +0100] [Job 103] Adding end banner page "none".
I [16/Nov/2009:11:20:17 +0100] [Job 103] File of type application/postscript
queued by "brunop".
I [16/Nov/2009:11:20:17 +0100] [Job 103] Queued on "PDF" by "brunop".
I [16/Nov/2009:11:20:17 +0100] [Job 103] Started filter
/usr/libexec/cups/filter/pstops (PID 18340)
I [16/Nov/2009:11:20:17 +0100] [Job 103] Started backend
/usr/libexec/cups/backend/cups-pdf (PID 18341)
I [16/Nov/2009:11:20:17 +0100] [Job 103] Completed successfully.

The
I
that starts each line
stands for “information.” In this case, no errors or warnings were
generated.

The Page Logfile

This logfile can be found in
/var/log/cups/page_log
. It keeps information
from each page sent to a printer. Each line contains the following
information (when
applicable
):

printer user job-id date-time page-number num-copies job-billing \
job-originating-host-name
jobname media sides

A sample excerpt follows:

Photosmart_C4500 brunop 86 [31/Oct/2009:12:48:36 +0100] 1 1 - localhost
Photosmart_C4500 brunop 86 [31/Oct/2009:12:48:52 +0100] 2 1 - localhost
adamp23 brunop 87 [02/Nov/2009:13:40:33 +0100] 1 1 - localhost
adamp23 brunop 87 [02/Nov/2009:13:40:33 +0100] 2 1 - localhost
adamp23 brunop 88 [09/Nov/2009:09:31:11 +0100] 1 1 – localhost
PDF root 100 [16/Nov/2009:11:11:52 +0100] 1 1 - localhost
PDF brunop 101 [16/Nov/2009:11:16:38 +0100] 1 1 - localhost
The Access Logfile

This file can be found in
/var/log/cups/access_log
. It lists each HTTP
resource accessed by a web browser or client. Each line is in an
extended version of the so-called “Common Log Format” used by many web
servers and web reporting tools. A sample follows (lines broken to fit
the page of this book):

localhost - - [16/Nov/2009:17:28:29 +0100] "POST / HTTP/1.1" 200 138 \
CUPS-Get-Default successful-ok
localhost - - [16/Nov/2009:17:28:29 +0100] "POST / HTTP/1.1" 200 552 \
CUPS-Get-Printers successful-ok
localhost - root [16/Nov/2009:17:28:29 +0100] "GET /printers HTTP/1.1" \
200 11258 - -
localhost - root [16/Nov/2009:17:28:29 +0100] "GET \
/images/button-search.gif HTTP/1.1" 200 332 - -
localhost - root [16/Nov/2009:17:28:29 +0100] "GET \
/images/button-clear.gif HTTP/1.1" 200 279 - -
Using the cups-config Utility for Debugging

The
cups-config
utility has several
parameters that can be handy while troubleshooting. The options are
described in
Table 18-2
.

Table 18-2. Options to cups-config

Option

Description

--cflags

Displays the necessary compiler
options.

--datadir

Displays the default CUPS data
directory.

--help

Displays the program usage
message.

--ldflags

Displays the necessary linker
options.

--libs

Displays the necessary libraries to
link to.

--serverbin

Displays the default CUPS binary
directory, where filters and backends are stored.

--serverroot

Displays the default CUPS
configuration file directory.

On the Exam

Be familiar with the CUPS logfiles, and how to interpret them to
troubleshoot printing issues.

Other books

Promise to Obey by Whitelaw, Stella
Define Me by Culine Ramsden
The Vault by Ruth Rendell
Dead Roots (The Analyst) by Brian Geoffrey Wood
A Matter of Principle by Kris Tualla
Kiss and Kill by Ellery Queen
Three Summers by Judith Clarke