Printing Documents with Fedora

Printing in Red Hat Linux is provided by the Common UNIX Printing System (CUPS) service. The LPRng service, which is no longer included with Fedora, still can be obtained from Red Hat FTP sites and some Fedora software repositories. Both services, however, let you print using the same basic set of printing commands described in this section.


For information on configuring local and remote printers for Fedora, see Chapter 17.

As a non-administrative user, you don’t have a lot of control over how the printers are configured. You can, however, check which printers are available to print to, check the status of print queues (documents waiting to print), and remove any of your own queued print jobs.

Printing to the default printer

When your system administrator (or you) configured printers for your computer, one of those printers was defined as the default printer. If you are not sure which printer is your default, type system-config-printer and look for the printer with the check by it.

Most graphical word processors, such as StarOffice and, let you choose a printer from those available. Some of the less sophisticated Linux utilities that run from the command line, however, use only the default printer. For example, dvips (to print a PostScript file) and groff -l (to print a troff/nroff file) automatically send the output to the default printer.

As a regular user, you can override the default printer using the PRINTER environment variable. For example, if the default printer on your computer is lp0 and you want to print regularly to lp1, change your default printer by setting the PRINTER variable as follows:

 $ export PRINTER=lp1  

To have this take effect all the time, you could add this line to one of your shell configuration files (such as $HOME/.bashrc, if you use the bash shell).

Printing from the shell

The lpr command is used to print files from the shell. You can use lpr to print whether the LPRng or CUPS print service is being used. If you have a file already formatted, use lpr to print it. For example, if you have a PostScript output file ( and you want to print it to your PostScript printer, use the following command line:

 $ lpr  

If you want to specify a particular printer (other than the default), add the -Pprinter option. For example, to print to the lp0 printer, you could type the following:

 $ lpr -Plp0  

If you want to print more than one copy of a document, use the -#num option, where num is replaced by the number of copies you want. For example, to print five copies of a file, use:

 $ lpr -#5  

The lpr command can also accept standard output for printing. For example, you could print the output of a groff command by piping that output to lpr as follows:

 $ groff -Tps -man /tmp/chown.1 | lpr -Plp0  

The enscript command (in the enscript package) is another useful tool for printing plain-text files. It converts the files to PostScript and sends them to a printer or to a specified file.

Checking the print queues

To check the status of print jobs that have been queued, you can use the lpq command. By itself, lpq prints a listing of jobs that are in the queue for the default printer. For example:

$ lpq  hp is ready and printing  Rank     Owner      Job  Files          Total Size  active   root       3    hosts          1024 bytes  1st      root       7    (stdin)        625 bytes  2nd      root       8       12273 bytes  3rd      chuck      9       10880 bytes 

The output from lpq shows the printer status and the files waiting to be printed. Rank lists the order in which they are in the queue. Owner is the user who queued the job. Job shows the job number. The Files column shows the name of the file or standard output (if the file was piped or directed to lpr). Total Size shows how large each file is in bytes.

You can add options to lpq to print different kinds of information. By adding -Pprinter, you can see the queue for any available printer. You can also add the job number (to see the status of a particular print job) or a user name (to see all queued jobs for a user).

Removing print jobs

If you have ever printed a large document by mistake, you understand the value of being able to remove a print job from the queue. Likewise, if a printer is going to be down for a while and everyone has already printed their jobs to another printer, it’s sometimes nice to be able to clear all the print jobs when the printer comes back online.

Remove print jobs in Fedora using lprm. For example, to remove all jobs for the user named bill (assuming you are either bill or the root user), type the following:

 $ lprm bill  

The root user can remove all print jobs from the queue. To do this you add a dash (-) to the lprm command line as follows:

 $ lprm -  

You can also remove queued print jobs for a particular printer (-Pprinter) or for a particular job number by just adding the job number to the lprm command line.

Checking printer status

Sometimes nothing comes out of a printer and you have no idea why. The lpc command is a printer status command that might give you a clue as to what is going on with your printer. The lpc command is intended for administrators, so it may not be in your default PATH. To start the lpc command, type the following:

# /usr/sbin/lpc  lpc> status  hp:               printer is on device 'lpd' speed -1               queing is enabled               printing is enabled               no entries               daemon present  lpc> 

When the command returns the lpc> prompt, type the word status. This example shows the status of printer hp. Here, queuing and printing are enabled. The printer shows no problems, no print jobs are waiting. To quit the lpc command, type exit at the lpc> prompt.

Red Hat Fedora Linux 3 Bible
Red Hat Fedora Linux 3 Bible
ISBN: 0764578723
EAN: 2147483647
Year: 2005
Pages: 286 © 2008-2017.
If you may any questions please contact us: