Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
Let The Music Play: Join EFF Today

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents
Up to --> Basic Administration

· Printers and Interfaces
· advanced formatting
· printcap
· remote printing

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Recommend Us
Surveys

Features
HOWTOs
News
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 255 guest(s) and 1 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  
Linux Tutorial - Basic Administration - Printers and Interfaces
  Terminal Settings ---- advanced formatting  


Printers and Interfaces

Under Linux, printing is managed and administered by several commands and files located in various parts of the system. The primary administrative directory is /usr/spool/. Each printer that you have configured has its own subdirectory, /usr/spool/lpd/<name>, where <name> is the name of the printer. In this subdirectory, you will find status information about the printer, as well as information about the jobs currently being printed.

The actual printing is done by the lpd daemon. On system start-up, lpd is started through one of the rc scripts (normally somewhere under /etc/rc.d). As it starts, lpd looks through the printer configuration file, /etc/printcap, and prints any files still queued (normally after a system crash).

In each spool directory is a lock file that contains the process id (PID) of the lpd process. The PID helps keep multiple printer daemons from running and potentially sending multiple jobs to the same printer at the same time. The second line in the lock file contains the control file for the current print job.

Management of the print system, or print spool, is accomplished through the lpc utility. This is much more than a "command" because it performs a wide range of functions. One function is enabling printing on a printer. By default, there is probably one printer defined on your system (often lp). The entry is a very simple print definition that basically sends all the characters in the file to the predefined port. (For the default printer on a parallel port, this is probably /dev/lp1.)

When a job is submitted to a local printer, two files are created in the appropriate directory in /usr/spool. (For the default printer, this would be /usr/spool/lp1). The first file, starting with cf, is the control file for this print job. Paired with the cf file is the data file, which starts with df and is the data to be printed. If you are printing a pre-existing file, the df file will be a copy of that file. If you pipe a command to the lpr command, the df file will contain the output of the command. Using the -s option, you can force the system to create a symbolic link to the file to be printed.

The cf file contains one piece of information on each of several lines. The first character on each line is an abbreviation that indicates the information contained. The information contained within the cf file includes the name of the host from which the print job was submitted (H), the user/person who submitted the job (P), the job name (J), the classification of the print job (C), the literal string used on the banner page to identify the user (L), the file containing the data (this is the df file) (f), which file to remove or "unlink" when the job is completed (U), and the name of the file to include on the banner page (N). If you check the lpd man-page, you will find about a dozen more pieces of information that you could include in the cf file. However, this list represents the most common ones.

In the same directory, you will find a status file for that printer. This file is called simply "status" and normally contains a single line such as

printing disabled

If you were to re-enable the printer, the line would then change to

lp is ready and printing

Looking at this line, you might have noticed something that might seem a little confusing. (Well, at least it confused me the first time). That is, we've been talking about the directory lp1 all along, but this says the printer is lp. Does this mean that we are talking about two separate printers? No, it doesn't. The convention is to give the directory the same name as the printer, but there is no rule that says you have to. You can define both the printer name and the directory any way you want.

This is probably a good time to talk about the printer configuration file, /etc/printcap. This file contains not only the printer definitions but the printer "capabilities" as well. In general, you can say the printcap file is a shortened version of the termcap file (/etc/termcap), which defines the capabilities of terminals.

In the printcap file, you can define a wide range of capabilities or characteristics, such as the length and width of each line, the remote machine name (if you are remote printing), and, as we discussed, the name of the spool directory. I will get into shortly what each of the entries means.

As we talked previously, the lpc command is used to manage the print spooler. Not only can you use it to start and stop printing, but you can use it to check the status of all the printer queues and even change the order in which jobs are printed.

There are two ways of getting this information and to manage printer queues. The first is to call lpc by itself. You are then given the lpc> prompt, where you can type in the command you want, such as start, disable, or any other administrative command. Following the command name, you must either enter "all," so the command will be for all printers, or the name of the printer.

The lpc program will also accept these same commands as arguments. For example, to disable our printer, the command would be

For a list of options, see the lpc man-page. A list of printer queue commands can be found in Table 0-1.

One aspect of the Linux print system that might be new to you is that you enable or disable the printing functionality within the kernel. Even though printer functionality is configured, you may not be able to print if you have hardware conflicts. When your run 'make configure' one of the options is to enable printing.

Once you have added the printer support to the kernel, the first thing you should do is test the connectivity by using the ls command and sending the output to the printer device. This will probably be /dev/lp0, /dev/lp1, or /dev/lp2, which corresponds to the DOS device LPT1, LPT2, and LPT3, respectively. For example, to test the first parallel port you could use

ls > /dev/lp0

What results is:

INSTALL@ dead.letter linux@ lodlin15.txt lodlin15.zip mbox sendmail.cf tests/

However, if you were to issue the command without the redirection, it would probably look like this:

INSTALL@ dead.letter linux@ lodlin15.txt lodlin15.zip mbox sendmail.cf tests/

The reason for this is that the ls command puts a single new-line character at the end of the line. Normally, the shell sees that new-line character and is told to add a carriage return onto the line. However, the printer has been told. Therefore, when it reaches the end of the line with the sendmail.cf, just a new line is sent. Therefore, the printer drops down to the next (new) line and starts printing again. This behavior is called "stair-stepping" because the output looks like stair steps. When a carriage return is added, the shell returns back to the left of the screen as it adds the new line.

Table - Print Queue Commands

Command

Function

lpc

Printer control program

lpd

Print spooler daemon

lpr

Print program

lpq

Print queue administration program

lprm

Remove jobs from print queue

pr

Convert text files for printing

 Previous Page
Terminal Settings
  Back to Top
Table of Contents
Next Page 
advanced formatting


MoreInfo

Test Your Knowledge

User Comments:


You can only add comments if you are logged in.

Copyright 2002-2009 by James Mohr. Licensed under modified GNU Free Documentation License (Portions of this material originally published by Prentice Hall, Pearson Education, Inc). See here for details. All rights reserved.
  




Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
You can help in many different ways.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.10 Seconds