Novell is now a part of Micro Focus

Newbie Lesson: Setting up SAMBA File Sharing and Windows Printing

Novell Cool Solutions: Feature
By Stomfi

Digg This - Slashdot This

Posted: 13 Aug 2004

Here are some tips on very simple ways of getting a Linux box sharing files and an MS Windows 98 printer. The tools we are using are Networking, SAMBA, Webmin, CUPS and LinNeighborhood. These instructions were written for some newbies who use MS Windows and who come to Computerbank Queensland for Linux lessons, so they are as easy as I can make them, using the easiest methods to do these sophisticated tasks.

These instructions presume you have all the necessary software installed on your Linux box and have working network cards on each box.

Connecting Linux and Windows boxes

First you need A WORKING CONNECTION between the Linux box and the MS Windows box. This is basic stuff and not covered here except to say that in simple networking, the IP addresses must be on the same network (ie., or otherwise you won't get a connection.

For this example I will use the following:

  • for the MS Windows box
  • for the Linux box.
  • The host names will be "swine" and "pearl"
  • The workgroup name will be SWINET
  1. Enable print and file sharing on "swine. You will have to perform the annoying MS reboot.
  2. After plugging in the network cabling, check the connections at each box with the command
    • ping
      in a DOS prompt window on MS, and
    • ping -c 5
      in shell terminal on Linux
    If successful, the ping command will send a few small requests to the other computer on the network (pearl or swine) and listen for a response. This step ensures that the machines are networked correctly and can 'see' each other in the most basic sense.

Getting SAMBA Connection

Presuming you got this far there are some important mandatory factors to get a SAMBA connection working.

It's all in the passwords, plus a bit of setup in the correct order.

In MS Windows
Make a new user or use settings/control panel/passwords to create a MS Windows user with a password, such as

user name = tom password = cbqcbq

Note these are all lower case.
Make sure the Windows work group is set to SWINET. (Right-click NetworkNeighborhood/ properties.)

On Linux
Make an account on Linux for your Windows login name making sure you give it the same password as your Windows one (in our example, tom & cbqcbq).

On Linux - as root - use the SAMBA password shell command which will prompt for the password:

smbpasswd -a tom

Now set up the SAMBA config file by copying the text below (delineated by #########) into your editor, and save the file into /etc/SAMBA/smb.conf

 ; /etc/SAMBA/smb.conf
; Sample configuration file for the SAMBA suite for Debian GNU/Linux
; Please see the manual page for smb.conf for detailed description of
;    every parameter.
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This is the file that Tom is using to connect a hard drive based
; Linux system to a Windows  box with Windows  printer
; See the Winprint instructions below for how to set up the printer using
; Webmin and Cups
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   printing = cups
   printcap name = cups
   guest account = nobody
   invalid users = root
; "security = user" is always a good idea. This will require a Unix account
;    in this server for every user accessing the server.
   security = user
; Change this for the workgroup your SAMBA server will part of
   workgroup = SWINET
   server string = %h server (SAMBA %v)
; If you want SAMBA to log though syslog only then set the following
;    parameter to 'yes'. Please note that logging through syslog in
;    SAMBA is still experimental.
   syslog only = no
; We want SAMBA to log a minimum amount of information to syslog. Everything
;    should go to /var/log/{smb,nmb} instead. If you want to log through
;    syslog you should set the following parameter to something higher.
   syslog = 0;
; This socket options really speed up SAMBA under Linux, according to my
;    own tests.
; Passwords are encrypted by default. This way the latest Windows  95 and NT
;    clients can connect to the SAMBA server with no problems.
   encrypt passwords = true
   passdb backend = smbpasswd guest
; It's always a good idea to use a WINS server. If you want this server
;    to be the WINS server for your network change the following parameter
;    to "yes". Otherwise leave it as "no" and specify your WINS server
;     below (note: only one SAMBA server can be the WINS server).
;    Read BROWSING.txt for more details.
   wins support = yes
; If this server is not the WINS server then specify who is it and uncomment
;    next line.
;   wins server =
# If we receive WINS server info from DHCP, override the options above.
;   include = /etc/SAMBA/dhcp.conf
; Please read BROWSING.txt and set the next four parameters according
;    to your network setup. There is no valid default so they are commented
;    out.
;   os level = 0
;   domain master = no
   local master = yes
;   preferred master = no
; What naming service and in what order should we use to resolve host names
;    to IP addresses
   name resolve order = lmhosts host wins bcast
; This will prevent nmbd to search for NetBIOS names through DNS.
   dns proxy = no
; Name mangling options
   preserve case = yes
   short preserve case = yes
; This boolean parameter controls whether SAMBA attempts to sync. the Unix
;    password with the SMB password when the encrypted SMB password in the
;    /etc/SAMBA/smbpasswd file is changed.
   unix password sync = true
; For Unix password sync. to work on a Debian GNU/Linux system, the 
;    parameters must be set (thanks to Augustin Luton
;    <> for sending the correct chat script for
;    the passwd program in Debian Potato).
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\sUNIX\spassword:* %n\n 
*Retype\snew\sUNIX\spassword:* %n\n .
; The following parameter is useful only if you have the linpopup package
;    installed. The SAMBA maintainer and the linpopup maintainer are
;    working to ease installation and configuration of linpopup and SAMBA.
;   message command = /bin/sh -c '/usr/bin/linpopup "%f" "%m" %s; rm %s' &
; The default maximum log file size is 5 MBytes. That's too big so this
;    next parameter sets it to 1 MByte. Currently, SAMBA rotates log
;    files (/var/log/{smb,nmb} in Debian) when these files reach 1000 
;    A better solution would be to have SAMBA rotate the log file upon
;    reception of a signal, but for now, we have to live with this.
   max log size = 1000
   obey pam restrictions = yes
; Some defaults for winbind (make sure you're not using the ranges
;    for something else.)
;   winbind uid = 10000-20000
;   winbind gid = 10000-20000
;   template shell = /bin/bash
; ISOLATIN1 with euro sign
 unix charset = iso-8859-15
 display charset = iso-8859-15
 dos charset = 850
   comment = Home Directories
   browseable = no
; By default, the home directories are exported read only. Change next
;    parameter to "no" if you want to be able to write to them.
   read only = yes
; File creation mask is set to 0700 for security reasons. If you want to
;    create files with group=rw permissions, set next parameter to 0775.
   create mask = 0700
; Directory creation mask is set to 0700 for security reasons. If you 
want to
;    create dirs. with group=rw permissions, set next parameter to 0775.
   directory mask = 0700
    printer = MSwinPrinter1  ; what we will call our MS printer
    browseable = no
    printable = yes
    writable = no
    path = /var/spool/cups
    comment = All Printers
    public = no
    create mode = 0700
   comment = User Public rw
   browseable = yes
   path = /usr/public
   printable = no
   public = yes
   writable = yes
   create mode = 0770
; A sample share for sharing your CD-ROM with others.
   comment = SAMBA server's CD-ROM
   writable = no
   locking = no
   path = /mnt/cdrom
   public = yes
; The next two parameters show how to auto-mount a CD-ROM when the
;    cdrom share is accessed. For this to work /etc/fstab must contain
;    an entry like this:
;       /dev/scd0   /cdrom  iso9660 defaults,noauto,ro,user   0 0
; The CD-ROM gets unmounted automatically after the connection to the
; If you don't want to use auto-mounting/unmounting make sure the CD
;    is mounted on /cdrom
;   preexec = /bin/mount /cdrom
;   postexec = /bin/umount /cdrom

Don't forget to save the file into /etc/SAMBA/smb.conf or wherever it goes on your distribution.

Restart the SAMBA server with the redhat command

service smb restart

or by going to the directory /etc/init.d and running the SAMBA startup file from there

eg ./SAMBA restart
or similarly /etc/init.d/SAMBA restart

You can always grep for SAMBA to find out your initialisation file name

grep SAMBA /etc/init.d/*

Make sure you set the /usr/public directory for open access

mkdir /usr.public
chmod +wrx /usr/public

  1. Now logon to your Windows box using the name and password you created (tom cbqcbq).
  2. Double-click Network Neighborhood.
  3. Double-click the hostname of your Linux box.
  4. use the same password (cbqcbq)
    If you followed these instructions so far you should now be able to access the Linux box.
    Try writing and saving a file to the public share on the Linux box

Getting Printer Working

Now for the Printer which should already be going on the "swine" box.

  1. On "swine" click on Settings/Printers and right-click the printer you want to share.
  2. Click "sharing" and click "shared as" and give it a share name (such as "hp").
  3. Open the Network Neighborhood Icon.
  4. Click on the local Machine Name (swine).
  5. Click on the Printer and write down the share name exactly as MS records it (\\Swine\hp).

Now for Linux.

Unlike older Linux network printing using LPD where the client connection sends a raw print file to be processed on the print server, Linux CUPS to MS Windows SAMBA printers uses the client printer driver. This had me stymied for about 10 minutes, until I hacked the solution.

(To Hack: To discover and apply a clever way of solving a problem. Something easily done on Linux, with all those lovely tools, but not so easy on MS Windows. At least I can't figure out how to.)

On Linux

  1. Fire up Webmin in your favourite browser by the address:

  2. Enter your webmin admin user name and password.
    root TAB cbqcbq ENTER
  3. Click the Hardware icon along the Webmin top bar.
  4. Click Printer Administration.
  5. Click Add new printer
  6. In the Printer Configuration Panel:
    1. Enter a name
      (such as - MSwinPrinter1)
    2. Enter description
      (such as - MS Windows Laser Printer)
    3. Leave the rest as is unless you need this as the default printer
  7. In the Printer Description Panel:
    1. Click Remote Windows server.
    2. Enter the MS Windows Machine Name (Swine).
    3. Enter the Printer Name (hp).
    4. At the bottom, click on Create.
    5. Return to Printer Admin and you will see your newly created printer with none in the Driver column.
  8. Click on the Servers icon.
  9. Click on SAMBA Windows File Sharing.
  10. Click on Restart SAMBA Servers down the bottom of page.
  1. Now put the address for CUPS in the browser address (http://pearl:631).
  2. Click on Printers on header bar.
    1. Your new Printer will be shown with the Name MSwinPrinter1 and Local Raw Printer
    2. The Device URL will be smb://Swine/hp
  3. Click on Modify Printer under the above line.
  4. Click Continue - Modify Printer MSwinPrinter1
  5. Click Continue - The Device - Windows Printer via SAMBA
  6. Click Continue - Device URL
  7. Click Continue - Model/Driver - This is what we will change. Our example Model is an HP and the Driver is for a LaserJet.
  8. Click HP
  9. Click Continue - Model/Driver
  10. Click HP LaserJet Series CUPS v1.1(en) - (For the CUPS version I am using) - Back to Admin
  11. Click MSwinPrinter1 - Shows page for MSwinPrinter1
  12. Click Print Test Page
  13. Click On the Job ID and you should see positive messages like:
    Printer state accepting jobs
    CUPS v 1.1 is ready to print
  14. If the Test page is no good, go back and Modify Printer again using a different Driver.
  15. If you have Gimp Print installed these may be the best drivers.

This is the finish of these hopefully simple tips and tricks for getting a working SAMBA file sharing and Windows printing.

You will notice I didn't mention using LinNeighborhood. You can try this in Linux but don't forget to set up the options to open up the mounted share with the file manager. This uses that other wonderful Linux tool "Midnight Commander."

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates