{"id":237,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:18","modified_gmt":"2020-08-22T20:26:18","slug":"this-is-the-page-title-toplevel-72","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=237","title":{"rendered":"Printers and Interfaces"},"content":{"rendered":"\n<title>Printers and Interfaces<\/title>\n<question id=\"139\" text=\"printer configuration information is stored in which directory?\" \/>\n<concept id=\"\" topic=\"Administration\" description=\"The primary printer administration directory is \/usr\/spool\" \/>\n<p>\nUnder Linux, printing is managed and administered by several commands\nand files located in various parts of the system. The primary administrative\ndirectory is <directory>\/usr\/spool<\/directory>. Each printer that you have configured has its own\nsubdirectory, \/usr\/spool\/lpd\/&lt;name&gt;, where &lt;name&gt; is the name of the\nprinter. In this <glossary>subdirectory<\/glossary>,\n you will find status information about the\nprinter, as well as information about the jobs currently being printed.\n<\/p>\n<concept id=\"\" topic=\"Administration\" description=\"The actual printing is done by the lpd daemon\" \/>\n<p>\nThe actual printing is done by the lpd <glossary>daemon<\/glossary>.\nOn system start-up, <command>lpd<\/command> is\nstarted through one of the <glossary>rc scripts<\/glossary> (normally somewhere under\n<directory>\/etc\/rc.d<\/directory>). As it starts, <command>lpd<\/command> looks through the\nprinter configuration file, <file type=\"\">\/etc\/printcap<\/file>, and\nprints any files still queued (normally after a system crash). <\/p>\n<p>\nIn each\nspool directory is a lock file that contains the process id (<glossary>PID<\/glossary>) of the <command>lpd<\/command>\nprocess. The <glossary>PID<\/glossary>\nhelps keep multiple printer daemons from running and\npotentially sending multiple jobs to the same printer at the same time. The\nsecond line in the lock file contains the control file for the current print\njob. <\/p>\n<question id=\"141\" text=\"what is the print administration program?\" \/>\n<concept id=\"\" topic=\"Administration\" description=\"Management of the print system, or print spool, is accomplished through the lpc utility.\" \/>\n<p>\nManagement of the print system, or print spool, is accomplished\nthrough the <command>lpc<\/command> utility. This is much more than a &#8220;command&#8221; because it\nperforms a wide range of functions. One function is enabling printing on a\nprinter. By default, there is probably one printer defined on your system (often\nlp). The entry is a very simple print definition that basically sends all the\ncharacters in the file to the predefined port. (For the default printer on a\nparallel port, this is probably <device>\/dev\/lp1<\/device>.)\n<\/p>\n<question id=\"140\" type= \"mc\" text=\"print job control files begin with what letters?\" \/>\n<question id=\"\" text=\"print job data files begin with what letters?\" \/>\n<concept id=\"\" topic=\"Administration\" description=\"Print job control files begin with the letters 'cf'.\" \/>\n<concept id=\"\" topic=\"Administration\" description=\"Print job data files begin with the letters 'df'.\" \/>\n<p>\nWhen a job is submitted to a\nlocal printer, two files are created in the appropriate directory in\n<directory>\/usr\/spool<\/directory>.\n(For the default printer, this would be <directory>\/usr\/spool\/lp1<\/directory>). The first file,\nstarting with cf, is the control file for this print job. Paired with the cf\nfile is the data file, which starts with df and is the data to be printed. If\nyou are printing a pre-existing file, the df file will be a copy of that file.\nIf you <glossary>pipe<\/glossary>\na command to the <glossary>lpr<\/glossary> command, the df  file will contain the output\nof the command. Using the -s option, you can force the system to create a\nsymbolic link to the file to be printed.  <\/p>\n<p>\nThe cf file contains one piece of information on each of several lines. The first character on\neach line is an abbreviation that indicates the information contained. The information contained\nwithin the cf file includes the name of the <glossary>host<\/glossary>\nfrom which the print job was\nsubmitted (H), the user\/person who submitted the job (P), the job name (J), the\nclassification of the print job (C), the literal string used on the banner page\nto identify the user (L), the file containing the data (this is the df file)\n(f), which file to remove or &#8220;unlink&#8221; when the job is completed (U),\nand the name of the file to include on the banner page (N). If you check the <command>lpd<\/command>\nman-page, you will find about a dozen more pieces of information that you could\ninclude in the cf file. However, this list represents the most common ones.\n<\/p>\n<p>\nIn the same directory, you will find a status file for that printer. This\nfile is called simply &#8220;status&#8221; and normally contains a single line\nsuch as\n<\/p>\n<p>\n<screenoutput>printing disabled<\/screenoutput>\n<\/p>\n<p>\nIf you were to re-enable the printer, the line would then change to<\/p>\n<p>\n<screenoutput>lp is ready and printing<\/screenoutput>\n<\/p>\n<p>\nLooking at this\nline, you might have noticed something that might seem a little confusing.\n(Well, at least it confused me the first time). That is, we&#8217;ve been talking about\nthe directory lp1 all along, but this says the printer is lp. Does this mean\nthat we are talking about two separate printers? No, it doesn&#8217;t. The convention\nis to give the directory the same name as the printer, but there is no rule that\nsays you have to. You can define both the printer name and the directory any way\nyou want.\n<\/p>\n<p>\nThis is probably a good time to talk about the printer\nconfiguration file, <file type=\"\">\/etc\/printcap<\/file>. This file contains not only the printer\ndefinitions but the printer &#8220;capabilities&#8221; as well. In general, you\ncan say the printcap file is a shortened version of the termcap file\n(<file type=\"\">\/etc\/termcap<\/file>), which defines the capabilities of terminals.\n<\/p>\n<p>\nIn the\nprintcap file, you can define a wide range of capabilities or characteristics,\nsuch as the length and width of each line, the remote machine name (if you are\nremote printing), and, as we discussed, the name of the spool directory. I will\nget into shortly what each of the entries means.\n<\/p>\n<p>\nAs we talked previously, the lpc command is used to manage the\n<glossary>print spooler<\/glossary>.\nNot only can you use it to start and stop printing, but you can use it to check the status of\nall the printer queues and even change the order in which jobs are printed.\n<\/p>\n<p>\nThere are two ways of getting this information and to manage printer\nqueues. The first is to call <command>lpc<\/command> by itself. You are then given the <command>lpc&gt;<\/command>\nprompt, where you can type in the command you want, such as start, disable, or\nany other administrative command. Following the command name, you must either\nenter &#8220;all,&#8221; so the command will be for all printers, or the name of\nthe printer. <\/p>\n<p>\nThe lpc program will also accept these same commands as\narguments. For example, to disable our printer, the command would be<\/p>\n<p>\n<commandexample command=\"lpc\">\nlpc disable lp1\n<\/commandexample>\n<\/p>\n<p>\nFor a list of options, see the lpc <glossary>man-page<\/glossary>.\n A list of printer queue commands can be found in Table\n<tablename>Print Queue Commands<\/tablename>.<\/p>\n<p>\nOne aspect of the Linux print\nsystem that might be new to you is that you enable or disable the printing functionality\nwithin the <glossary>kernel<\/glossary>.\nEven though printer functionality is configured, you may not\nbe able to print if you have hardware conflicts. When your run &#8216;make configure&#8217;\none of the options is to enable printing.<\/p>\n<p>\nOnce you have added the printer support to the <glossary>kernel<\/glossary>,\n the first thing you should do is test the connectivity by\nusing the ls command and sending the output to the printer device. This will\nprobably be <device>\/dev\/lp0<\/device>, <device>\/dev\/lp1<\/device>, or\n <device>\/dev\/lp2<\/device>, which corresponds to the <glossary>DOS<\/glossary>\ndevice LPT1, LPT2, and LPT3, respectively. For example, to test the first parallel port\nyou could use<\/p>\n<p>\n<commandexample command=\"ls\">ls &gt; \/dev\/lp0 <\/commandexample>\n<\/p>\n<p>What results is:<\/p>\n<screenoutput>INSTALL@   dead.letter     linux@  lodlin15.txt    lodlin15.zip\n        mbox    sendmail.cf        tests\/\n<\/screenoutput>\n<p>However, if you were to issue the command without the <glossary>redirection<\/glossary>,\nit would probably look like this: <\/p>\n<p>\n<screenoutput>\nINSTALL@\ndead.letter\nlinux@\nlodlin15.txt\nlodlin15.zip\nmbox\nsendmail.cf\ntests\/\n<\/screenoutput>\n<\/p>\n<question id=\"142\" text=\"a print output that 'stair steps' is usually caused by not sending carriage returns.\" \/>\n<concept id=\"128\" description=\" A print output that 'stair steps' is usually caused by not sending carriage returns.\" \/>\n<p>The reason for this is that the ls command puts a single new-line\ncharacter at the end of the line. Normally, the <glossary>shell<\/glossary>\nsees that new-line character and is told to add a <glossary>carriage return<\/glossary>\nonto the line. However, the printer has been told. Therefore, when it reaches the end\nof the line with the <file type=\"\">sendmail.cf<\/file>, just a new line is sent. Therefore, the printer drops\ndown to the next (new) line and starts printing again. This behavior is called\n&#8220;stair-stepping&#8221; because the output looks like stair steps. When a\ncarriage return is added, the <glossary>shell<\/glossary>\nreturns back to the left of the screen as it\nadds the new line. <\/p>\n<question id=\"\" type=\"mc\" text=\"What command is used to delete all current print jobs?\" \/>\n<question id=\"\" type=\"mc\" text=\"What command is used to administer the printer queue?\" \/>\n<p>\n<tablelabel text=\"Print Queue Commands\" >\nTable &#8211; Print Queue Commands\n<\/tablelabel>\n<\/p>\n<p><center><table BORDER cellspacing=1 CELLPADDING=7 WIDTH=447><tr>\n<td><b>\n<p>Command<\/b><\/td><td><b>\n<p>Function<\/b><\/td><\/tr>\n<tr><td>\n<p><command>lpc<\/command><\/td><td>\n<p>Printer control program<\/td><\/tr>\n<tr><td><p><command>lpd<\/command><\/td><td>\n<p>Print spooler daemon<\/td><\/tr>\n<tr><td>\n<p><command>lpr<\/command><\/td><td>\n<p>Print program<\/td><\/tr>\n<tr><td>\n<p><command>lpq<\/command><\/td><td>\n<p>Print queue administration program<\/td><\/tr>\n<tr><td>\n<p><command>lprm<\/command><\/td><td>\n<p>Remove jobs from print\nqueue<\/td><\/tr>\n<tr><td>\n<p><command>pr<\/command><\/td><td>\n<p>Convert text files for printing<\/td><\/tr><\/table><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\/&lt;name&gt;, where &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=237\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-237","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=237"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/237\/revisions"}],"predecessor-version":[{"id":666,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/237\/revisions\/666"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}