Wednesday, June 01, 2011

Linux Based Printing configuration

     Configuring a Printer in Linux is easier,if you find the right driver to that Printer. If there is no proper Driver then we may use the Generic Driver, but it may not give the desired Output.
  
    In Red Hat Enterprise Linux 4 (RHEL 4), setuptool can be installed to configure and install an existing printer.By default the RedHat Linux comes with two different printing systems : LPRng and CUPS. 

LPRng :

To use the Printer Configuration Tool, it is must to be logged in as root.
Printer Configuration Tool can be started in 2 different ways:

i) In a graphical desktop environment, click Main Menu => System Settings => Printing.
ii) Type the command redhat-config-printer at a shell prompt (for example, in a command-line terminal window) to start the graphical version.Remember this command only works when DISPLAY variable is exported and the when you could able to access the GUI Screen of Linux

In case if the X server is not installed on Linux, and if you're looking for configuring the printer from text based screen then it can be either called from the setuptool or using system-config-printer-tui commnd. Which allows you to configure the Printer.

Internally the setuptool also calls  system-config-printer-tui comamnd. All the files related to setuptool are stored under the /etc/setuptool.d directory.

The Other System in Linux to Enable the Printing is CUPS.

Overview of CUPS

CUPS is the software you use to print from applications like the web browser you are using to read this page. It converts the page descriptions produced by your application (put a paragraph here, draw a line there, and so forth) into something your printer can understand and then sends the information to the printer for printing.
Now, since every printer manufacturer does things differently, printing can be very complicated. CUPS does its best to hide this from you and your application so that you can concentrate on printing and less on how to print. Generally, the only time you need to know anything about your printer is when you use it for the first time, and even then CUPS can often figure things out on its own.

How Does It Work?

The first time you print to a printer, CUPS creates a queue to keep track of the current status of the printer (everything OK, out of paper, etc.) and any pages you have printed. Most of the time the queue points to a printer connected directly to your computer via a USB or parallel port, however it can also point to a printer on your network, a printer on the Internet, or multiple printers depending on the configuration. Regardless of where the queue points, it will look like any other printer to you and your applications.
Every time you print something, CUPS creates a job which contains the queue you are sending the print to, the name of the document you are printing, and the page descriptions. Job are numbered (queue-1, queue-2, and so forth) so you can monitor the job as it is printed or cancel it if you see a mistake. When CUPS gets a job for printing, it determines the best programs (filters, printer drivers, port monitors, and backends) to convert the pages into a printable format and then runs them to actually print the job.
When the print job is completely printed, CUPS removes the job from the queue and moves on to any other jobs you have submitted. You can also be notified when the job is finished, or if there are any errors during printing, in several different ways.

After a above brief note, it can be concluded that the Major tasks performed by the linux System to print any document, it uses the CUPS as its interface. CUPS manages all the Print Documents and Queues.

How to Configure a Printer in Linux:

Before configuring the printer, it is necessary to look of the RPMS required to configure a Printer are available in the system or not.

Use the following command:

                 rpm -qa | grep cups

If the there are no rpms installed for cups, it is required to install the cups RPM from the Linux installation Disks.

All the commands used above to configure the printer, works well till Red Hat Enterprise Linux 4. But from the RHEL 5 printconf-tui has been deprecated.  

printconf-tui is no longs available in the RHEL 5. WHY???

In Red Hat Enterprise Linux there used to be a command line tool for importing and exporting CUPS configuration. In fact it was part of the printconf system: the previously-exported XML file would be imported into printconf’s own configuration, and printconf would then write new CUPS configuration based on that.
Red Hat Enterprise Linux 5 provides a re-written printing administration tool (still called system-config-printer), avoiding the many problems of the “separate configuration” approach. Now CUPS is configured directly using IPP, and this can be done remotely. The new system-config-printer tool does things in the same way as the CUPS web interface and the CUPS command line tools, and so they can all be used interchangeably.

MANAGING CUPS:

Often a print server will be installed with as little software as possible, and this means no graphical utilities. There are two ways to configure the CUPS server in this case: the most obvious one is to use the CUPS web interface on that machine. On a graphical desktop machine, point a web server to http://the-printer-server:631 and configure away.

The other way is to use system-config-printer on the desktop machine, but tell it to configure the print server’s CUPS instance rather than the one on the local machine (“Goto Server”). Just make sure to allow remote administration on the print server first; you can do that via the CUPS web interface.
The following steps can be used to configure the Printer using the CUPS web interface locally:

1. Download the PPD's of respective printers from their websites.
2. Su - root
3. mkdir /usr/share/cups/model/(Printer Manufacturer name)
4. cp *.ppd /usr/share/cups/model/foldername
5. service cups restart
6. Open the conqueror or mozilla
7. http://localhost:631
8. Click Administration tab
9. It prompts for user name & password(give root & its password)
10. Add printer
11. Give printer name (It should not contain space ,any special characters)
12. Enter location
13. Enter Descriptions
14. Device-Internet Printing Protocol
15. Device-URL-socket://hostname:9100 (Give the hostname of the printer)

The above only works if you have the X Display Server installed either with the GNOME or KDE.If you want to configure without KDE or GNOME, the best way is to configure using the CUPS Web Interface by accessing it remotely. But by default this feature is disabled, needs the following steps to configure and to enable this feature.
(Before Editing the cupsd.conf file, it is better to take a backup of this file)

1. Edit the cups configuration file by first running the following command on your server:

vi /etc/cups/cupsd.conf

2. Edit the file is to make the section that looks like:

# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock

look like this:

# Only listen for connections from the local machine.
Port 631
Listen /var/run/cups/cups.sock

3. You then have to change the sections that looks like this:

< Location / >
# Restrict access to the server...
Order allow,deny
< /Location >
< Location /admin >
# Restrict access to the admin pages...
Order allow,deny
< /Location >
< Location /admin/conf >
AuthType Default
Require user @SYSTEM
# Restrict access to the configuration files...
Order allow,deny
< /Location >

to change like as follows:

< Location / >
# Restrict access to the server...
Order allow,deny
Allow all
< /Location >
< Location /admin >
# Restrict access to the admin pages...
Order allow,deny
Allow all
< /Location >
< Location /admin/conf >
AuthType Default
Require user @SYSTEM
# Restrict access to the configuration files...
Order allow,deny
Allow all
< /Location >

4. Finally, restart cups service:

service cups restart
     
 5. Now access the url from a remote server as:

http://yourservername:631

Note that when you change something, it may tell you that you need to add a certificate to firefox. Do so by clicking the add/get certificate button at the bottom of the firefox error message page. It will also tell you that to change stuff, you need to use the "https" version of the page instead of "http" so just go to:
https://yourserverip:631
You might also have to open/port forward port 631.

An addition would be that instead of doing "Allow from all", you can use "Allow from @LOCAL" and it restricts access to your local network. 

No comments: