Printing with Linux
- — 15 November, 2000 13:10
ADDING A PRINTER
If you did not set up your printer during installation or you are adding a new printer, a useful program for doing this "is Red Hat's Printtool. Other distributions have printer configuration tools, however, Printtool is well suited for beginners. This program has a graphical interface and can be used to configure either a local or network printer. For ease of use it is recommended over manually editing the /etc/printcap configuration file. The software that controls the print spooling is the line-printer deamon (lpd), and although there are other programs available for Linux such as PDQ and LPRng, lpd is the most popular.
Before you attempt to add a printer, you should connect it to the computer first. This allows Printtool to detect the printer's location. To use Printtool you will need to be running X Windows and be logged into a terminal as root, then type:
The Linux Print System Manger window will appear and you have the "option to edit, add or delete a printer. Selecting "add" will give you the choice of adding a local, remote Unix, SMB/Windows (Samba) or NetWare printer.
If you chose to add a local printer, Printtool will attempt to detect the location of the printer. Clicking OK once the correct location is detected will reveal the Edit Local Printer window: here you will need to assign a name for the printer, the spool directory (which is usually /var/spool/lpd/printer where printer is the name of your printer, e.g., Epson800), the file limit and the input filter. The input filter is where various printer specifications such as model selection, text or PostScript, printing resolution and paper size are set. Once the new printer is installed, print a test page from the Tests menu. If printing does not work, try restarting lpd or editing the input filter settings.
Printtool will also help you configure a remote (network) printer for your Linux system. Adding a remote printer is much the same as adding a local printer, apart from a few specific configuration parameters. If you intend to add support for a remote Unix printer, you will need to specify the hostname of the computer, which controls the printer as well as the remote queue. Similarly, adding an SMB/Windows printer involves the same information, such as a local name and a TCP/IP hostname. However, you will also need to include the remote printer name, a user name and a password. Finally, you can also add a NetWare printer by specifying the NetWare server name for the printer and the print queue name. To be able to print to a NetWare printer, you must have the package's ncpfs (NetWare NCP file system program) and ipxutils (IPX file transfer protocol utilities) installed.
This month's cover CD includes the necessary programs for printer configuration as well as the Linux Printing HOWTO from the Linux Documentation Project.
When you start your computer, the lpd process begins by reading the /etc/printcap file to see which printers are set up (either locally or over a network) and handle print job requests. If lpd is running and your printer is configured, you can use the offline print (lpr) command to print files. For example:
$ lpr linux.txt
will print the text file "linux.txt". As with most other Linux commands, lpr supports various options or "flags" that can be added for specific purposes. Issuing the command:
$ lpr -P printer2 -#5 linux.txt
will tell "printer2" to print five copies of "linux.txt". The -P option is used to specify which printer to print to and is used when more than one printer is supported by your computer. Also, the -#n option specifies the number of pages to be printed (replace n by the number of pages). See the manual page by typing man lpr at the command prompt for more details about lpr.
Just as lpr can be used to send jobs "to the print queue, the lprm command can be used to remove them. To remove "the current jobs from a particular printer, all a user needs to do is execute:
$ lprm -P printer2
Similarly, a root user can remove all the print jobs for a specific user by issuing:
$ lprm tux
where tux is a username. To remove a specific job you will need to know the job number first, which is determined with the lpq command. Issuing lpq will display a list of the current jobs waiting to be printed. Typing:
$ lpq -l
will also display the job number. Therefore, using lprm, you can remove a specific job by typing:
$ lprm jobnumber
where "jobnumber" is replaced by the number assigned to that job.
Whether you have configured your printer during installation or with a program such as Printtool, printing with Linux is a very useful tool. Particularly useful features include network printing and the ability to control jobs that are in the queue.