Monday, 2 July 2012

Configure linux printer server step by step guide and Printer Sharing Configuration.

Configure linux printer server step by step guide example and implementation:

Linux uses the Common UNIX Printing System, also known as CUPS. CUPS uses the Internet Printing Protocol (IPP) to allow local printing and print sharing. The /etc/cups/ directory stores all the configuration files for printing. However, these files can be easily managed with the Printer Configuration Tool in Linux.

Exam question
Raw (Model) printer named printer1 is installed and shared on You should install the shared printer on your PC to connect shared printer using IPP Protocols.

Exam question
Raw printer named printerx where x is your station number is installed and shared on Install the shared printer on your PC to connect shared printer using IPP Protocols. Your server is
Before you can use any printer, you first have to install it on a Linux system on your network.

To start the Printer Configuration Tool, go to the System menu on the top panel and select Administration, Printing or execute the command:

printer path
If no printers are available for the system, only the Server Settings view is available for selection. If local printers are configured, a Local Printers menu will available.
Install new printer:
click New Printer on the toolbar.

new printer

In the dialog window that appears, accept the default queue name or change it to a short, descriptive name that begins with a letter and does not contain spaces. Then select printer from list and click on forward and click on finsh.

spool directories
When your system prints a file, it makes use of special directories called spool directories. The location of the spool directory is obtained from the printer's entry in its configuration file. On Linux, the spool directory is located at /var/spool/cups under a directory with the name of the printer.

print job
A print job is a file to be printed. When you send a file to a printer, a copy of it is made and placed in a spool directory set up for that printer.

CUPS features a way to let you select a group of printers to print a job instead of selecting just one. That way, if one printer is busy or down, another printer can be automatically selected to perform the job. Such groupings of printers are called classes. Once you have installed your printers, you can group them into different classes.

Once you have successfully installed local printer it will show in right pane. and in left pane you can see all administrative options.

printer option
  • To view shared printer on other system Tick mark on first option
  • To share locally attached printer tick mark on second option
  • To allow remote administration of this printer check mark on third option
Tick mark on appropriate option and click on apply
share printer from server
configure window clients:
Go on window system and ping from printer server and open internet explorer and give the ip address of server with printer port 631

internet explorer
This will launch CUPS web application click on manage printer
manage printer
now you will see the shared printer on server click on print test page
print test page
A test page will be send on printer server copy this url of printer
copy url
click on start button select printer and fax and click on add new printer. this will launch add new printer wizard click next on welcome screen and select network printer
network printer
On this screen select internet printer and paste the url which you copied from internet explorer
internet printer
Install appropriate driver from list or use have disk option you have drive cd and click next. On next screen set this printer defaults and click on next and finish.
set defaults

Remote administration of print server:

Go on linux system and ping from server and click on printing from administration menu
printer path
Now click on go to server
go to printer server
Now give print server ip address
ip address of print server
It will take few minute to connect from server depending on network speed
Now give root password to connect printer server
root password
you can see all print administrative Manu in right pane Once you have connected with sever
print server options

configure Linux clients:

Go on linux system and ping from server and click on printing from administration menu
printer path
Now click on new printer
new printer
Click on forward In the next New Printer screen, select the type of connection to internet printing protocols and in hostname give server ip and printer name in printername
select ipp
select the appropriate model. If multiple drivers are available, select the one most appropriate for your configuration. If you do not want to choose the default and click forward and finish. The main Printer Configuration window should now include the name of your printer.
make default
To print test page click on print test page and a test page will send to print server
print test page

Managing Printers from the Command-Line:

The lpadmin command enables you to perform most printer administration tasks from the command-line.
 lpc To view all known queues
 lpr To send print requests to any local print queue 
 lpq To see the print queue  
lprm To delete the jobs of your choice use it with the job number 

 lp To print any file. 

CUPS printer sharing:

1.Manual setup

simply open up /etc/cups/cupsd.conf and allow access to the server by modifying the location lines.

#vim /etc/cups/cupsd.conf

<Location />
   Order allow,deny
   Allow localhost
   Allow 192.168.0.*

Also make sure the server is listening on the IP address the client will
be addressing. Add the following line after "# Listen
<serverip>:631" (using the server's IP address instead of client's


To "Show shared printers on the local network", add the line "BrowseAllow all":

Browsing On BrowseOrder allow,deny BrowseAllow @LOCAL BrowseAllow all After making modifications, restart CUPS by:

# /etc/rc.d/cupsd restart 

On the client system, open up (create if not present) /etc/cups/client.conf and add the ServerName to match the IP address or the name of the server. Add this line:

To "Show shared printers on the local network", add the line

"BrowseAllow all":

Browsing On 
BrowseOrder allow,
deny BrowseAllow @LOCAL
BrowseAllow all 

There are more configuration possibilities, including automatic methods, which are described in detail in http://localhost:631/help/network.html
After making modifications, restart CUPS.
Note: When adding the printer from the client, if using the Internet Printing Protocol (IPP), put the URI as ipp://<name-of-printer>

Case1: Linux server - Windows client:

1.Sharing via IPP:

The preferred way to connect a Windows client to a Linux print server is using IPP. It's a standard printer protocol based on HTTP, allowing you all ways to profit from port forwarding,

On the Windows computer, go to the printer control panel and choose to 'Add a New Printer'. Next, choose to give a URL. For the URL, type in the location of the printer: http://host_ip_address:631/printers/printer_name (where host_ip_address is the GNU/Linux server's IP address and printer_name is the name of the printer being connected to). 

After this, install the native printer drivers for your printer on the Windows computer. If the CUPS server is set up to use its own printer drivers, then you can just select a generic postscript printer for the Windows client(e.g. 'HP Color LaserJet 8500 PS' or 'Xerox DocuTech 135 PS2'). Then test the print setup by printing a test page.

 2.Sharing via Samba:

 This makes this way more difficult to configure and thus sometimes also more error-prone, mostly due do authentication problems.

To configure Samba on the Linux server, edit /etc/samba/smb.conf file to allow access to printers. File smb.conf can look something like this:

#vim /etc/samba/smb.conf

server string=Arch Linux Print Server

    comment=All Printers
    # to allow user 'guest account' to print.
    guest ok=no
    create mode=0700
    write list=@adm root yourusername
 That should be enough to share the printer, yet adding an individual printer entry may be desirable:

    comment=Samsung ML-1250 Laser Printer
    printer admin=@admin root yourusername
    user client driver=yes
    # to allow user 'guest account' to print.
    guest ok=no
    write list=@adm root yourusername
    valid users=@adm root yourusername
Please note that this assumes configuration was made so that users must have a valid account to access the printer. To have a public printer, set guest ok to yes, and remove the valid users line. To add accounts, set up a regular GNU/Linux account and then set up a Samba password on the server. For instance:

# useradd yourusername
# smbpasswd -a yourusername

After this, restart Samba daemon:
# /etc/rc.d/samba restart
Case2: Windows server - Linux client

Sharing via LPD

Windows 7 has a built-in LPD server - using it will probably be the easiest approach as it does neither require an installation of Samba on the client nor heavy configuration on the server. It can be activated in the Control Panel under Programs -> Activate Windows functions in the section Print services. The printer must have shared activated in its properties. Use a share name without any special characters like spaces, commas, etc.
Then the printer can be added in CUPS, choosing LPD protocol. The printer address will look like this:
# lpd://windowspc/printersharename
Before adding the printer, you will most likely have to install an appropriate printer driver depending on your printer model. Generic PostScript or RAW drivers might also work.

Sharing via IPP

As above, IPP is also the preferred protocol for printer sharing. However this way might be a bit more difficult than the native Samba approach below, since you need a greater effort to set up an IPP-Server on Windows. The commonly chosen server software is Microsoft's Internet Information Services (IIS).
Note: This section is incomplete. Here is a description how to set up ISS in Windows XP and Windows 2000, unfortunately in German [1]

Sharing via Samba

A much simpler way is using Window's native printer sharing via Samba. There is almost no configuration needed, and all of it can be done from the CUPS Backend. As above noted, if there are any problems the reason is mostly related to authentication trouble and Windows access restrictions.
On the server side enable sharing for your desired printer and ensure that the user on the client machine has the right to access the printer.
The following section describes how to set up the client, assuming that both daemons (cupsd and smbd) are running.
Configuration using the web interface
The Samba CUPS back-end is enabled by default, if for any reason it is not activate it by entering the following command and restarting CUPS.
# ln -s $(which smbspool) /usr/lib/cups/backend/smb
Next, simply log in on the CUPS web interface and choose to add a new printer. As a device choose "Windows Printer via SAMBA".
For the device location, enter:
Or without a password:
Make sure that the user actually has access to the printer on the Windows computer and select the appropriate drivers. If the computer is located on a domain, make sure the user-name includes the domain:
If the network contains many printers you might want to set a preferred printer. To do so use the web interface, go into the printer tab, choose the desired printer and select 'Set as default' from the drop-down list.
Manual configuration
For manual configuration stop the CUPS daemon and add your printer to /etc/cups/printers.conf, which might for example look like this
<DefaultPrinter MyPrinter>
AuthInfoRequired username,password
Info My printer via SAMBA
Location In my Office
MakeModel Samsung ML-1250 - CUPS+Gutenprint v5.2.7        # <= use 'lpinfo -m' to list available models
DeviceURI smb://username:password@hostname/printer_name   # <= server URI as described in previous section
State Idle
Type 4
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
AllowUser yourusername                                    # <= do not forget to change this
OpPolicy default
ErrorPolicy stop-printer
Then restart the CUPS daemon an try to print a test page.
To set the preferred printer use the following command
# lpoptions -d desired_default_printer_name


If there are any problems, the first thing to do is enable debug information by setting
LogLevel debug
in /etc/cups/cupsd.conf. Then restart the CUPS daemon and check for error messages in /var/log/cups/error_log. A convenient way to do so is
# tail -f /var/log/cups/error_log
which keeps printing new error messages as the occur.
Note: You can also use the web interface to browse this error file.


How to share a local printer on Linux with Windows using Samba:

Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients.

1. Install samba - Use yum to install samba for your Fedora release.

$ sudo yum install samba
2. Configure samba - Edit following section in your smb.conf file. (Here is my complete smb.conf file.)

$ sudo vi /etc/samba/smb.conf

   workgroup = WORKGROUP
   security = share

# Share Printer (2005-01-02 by Thomas Chung)
   printing = cups
   public = yes
   printer name = epson
   use client driver = yes

$ sudo /sbin/chkconfig smb on
$ sudo /sbin/service smb restart
3. Configure iptables - Add following rules to your iptables to accept NETBIOS session service from Windows.

$ sudo vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 139 -j ACCEPT

$ sudo /sbin/service iptables restart
4. Add printer from Windows. (Following screenshots were taken from Windows 2000)
1) Choose Start > Settings > Printers

2) Choose Network printer

3) Type printer name as following. Make sure to substitute with your Linux IP address and Samba printer name.

4) You will see following message since there is no Windows printer driver on Linux. Click OK.

5) Select your model of your printer from following. You might need to install a printer driver from a CD came with the printer.

6) You've added printer driver successfully.

7) Now, print a test page from Windows to the printer which is attached to Linux box.


How can I set up my printer from within Linux to be accessible from my Windows 7 pc?

Step 1: Enable Sharing for that Printer.
Menu > Administration > Printing > Right Click the attached printer > Properties > Policies
Check Enabled, Accepting Jobs, and Shared

Step 2: Enable Publishing of the Shared Printer

Menu > Administration > Printing > Server > Settings > Check "Publish Shared Printers connected to this system"

Step 3: Allow guest access to printer

Edit smb.conf as root:

#gedit /etc/samba/smb.conf

Change the "guest ok" line from no to yes in the [printers] special share:
comment = All Printers
browseable = No
path = /var/spool/samba
printable = yes
guest ok = yes
read only = yes
create mask = 0700

Step 4: Restart these services in this exact order:
sudo service cups restart
sudo service smbd restart


Ref url's:

To share pinter linux to linux:


  1. Nice blog & thanks for sharing this useful information with us. We offer 24*7 printer support services to the customers across the world. Our expert team provides assistance for wireless printer setup, so if you are facing setup issues you can call us at our toll free number +1-888-339-8933 .

  2. The best selection of, thank you for work you have done. Your whole text is very useful. Also visit the HP Printer Helpline Number for getting more info about it.