-->
Previous | Table of Contents | Next |
Whenever you submit a print request, Linux responds with a print request ID number. This is sometimes suppressed by applications but usually shown when you print from a command line. The command to print a file from the shell prompt is usually the lp command followed by the filename or a wildcard, such as the following:
lp file1.txt
When this command is executed, the system returns the print request ID number:
request id is hplj-307 (1 file)
In this case, the request ID number is hplj_307, which tells you the printers name (hplj) and that this is the 307th print request that printer has handled since the counter started at zero. The total number after the request ID shows how many files are to be printed (in this case, one). If wildcards had been used, this number may be different, as shown in this example:
lp text*.doc request id is hplj_308 (12 files)
In this case, even though we have printed 12 files, only one print request ID number is assigned to that bunch. This is normal: Linuxs printing utilities treat each individual print request (no matter how many files or pages are involved) as a single request.
After an application has submitted a print request and the data has been copied to the spool directory, a printer daemon looks at the directory contents and arranges to print the files in order. This print daemon is running all the time and simply looks at the spool directories checking for new arrivals. When one comes in, the daemon checks that the destination printer is available and then sends the data to the printer. If the printer is busy or not available for some other reason, the daemon holds the print request until it can be queued. The printer daemon can also prioritize print requests if instructed to by users.
Many useful commands let you see what youve queued to the printers and what the print request IDs are, and they let you manage the queue a little. The system administrator can manage any print request and the queues, but users can usually only manage their own print requests. Several commands supported by Linux versions do much the same thing, so check your own system to see which commands are provided.
To find out all the print requests that are in the print queue (stored in the spool directory), you can use the lpq command. When run, lpq shows the files in the printer and their current location in the queue. This lets you judge how long it will take for your jobs to print. Some systems allow the lpstat command to show the same thing. If you have nothing in the queue, lpstat wont show you anything. It only shows your requests unless you use the -t option, in which case lpstat shows the entire print queue, as well as status messages about each printer the system knows about. Many Linux systems use the lpc command to show current status of all printers.
To remove a print request from the queue, most Linux systems use the lprm command followed by the print request ID number, such as the following:
lprm hplj-307
Some systems allow you to use the cancel command in the same way:
cancel hplj-307
You will often get a message back from the system telling you that the print job has been canceled or rm-ed from the queue:
request hplj-307 canceled
In this chapter youve seen how Linux handles printers and device drivers, as well as how filters are involved. Linux has scripts that install printers for you automatically, so going through the tedious and troublesome procedure of manually installing a printer, setting up the queues, and checking file and directory permissions will be skipped. From here, there are a number of chapters you may want to read to learn more:
Previous | Table of Contents | Next |