Linux PowerHouse Station Logo Linux PowerHouse Station Banner
Presented by: Kimmie Dicaire
And the #linuxhelper@dal.net ops
3 walking penguins
Home

Distributions
HOWTOs
Tutorials
Man Pages
Help Database
Basic Commands
Security/Patches
Editorials
Hot Links
Channel Operators
Channel Rules

Credits
Feedback
Email Kimmie
About Kimmie
Kimmie's Resume
Samba

This tutorial is written based on Slackware 7.0 and Samba 2.0.7 networked with Win98. This is start from scratch download and manual compile of Samba, this tutorial does NOT follow the same basic procedures as if Samba had been installed during a Linux distribution installation such as RedHat, Debian, or even the standard Slackware distribution installation. It is recommended that you uninstall Samba that came with your distribution installation if you want to follow this tutorial. With that said on with the show.

First of all you will need to go download the latest tar of the Samba source, which you can get athttp://www.samba.orgDo your part in dividing up the site's bandwidth by choosing the mirror closest to you.

While you are waiting on the download lets make sure you have smbfs support in your kernel. If you have never compiled a kernel and need help seeSection Eight - Kernel Compiles. Check to make sure that Filesystems -> Network Filesystems -> has either a < * > or < M > in it. If that is set you are doing good and can continue with the next section, if not then you will need to make that change and recompile your kernel.

< M >SMB filesystem support (to mount WfW shares etc.)

Now that you have your tarball put it in /usr/src and lets compile it.

  1. mv samba-latest.tar.gz /usr/src
  2. tar zxfv samba-latest.tar.gz
  3. cd samba-2.0.7
  4. For just a basic compile use the following commandline.Note:If you are using RedHat or any other distribution that requires PAM then you will need to read the README to find the appropriate commandline.
    • configure --with-smbmount --with-syslog --with-privatedir=/usr/local/samba/private --with-lockdir=/usr/local/samba/var/locks
    Note:For a complete list of all the options do configure --help
  5. Now we are ready to make the programs so type make
  6. Now install by typing make install

Well the easy part is done, a nice straight forward compile, make and install. The next few steps of actually configuring takes a little more know how. I will try to explain each step as we go so that you can understand exactly what you are doing.

First you will need to have a smb.conf in your /usr/local/samba/lib directory. You can grab the sample one from /usr/src/samba-2.0.7/examples called smb.conf.default or you can grab the sample one I have athere.

This is the file where you begin to lay the plan for your network and define the shares that will be available on your linux machine. This is where it starts to get a little more complicated so stick with me. The following will be a section by section explaination of the smb.conf and where you will need to make the decisions on how Samba is going to work and be a part of your network.

[global]
# workgroup = NT-Domain-Name or Workgroup-Name
workgroup = WORKGROUP

In the above section you will name your workgroup. If you already have a workgroup name on your network then use that in place of WORKGROUP otherwise for the sake of this tutorial leave it as WORKGROUP. This field is mandatory no matter how you intend to use Samba on your network. This name ties your linux machines to your Win9x/NT machines.

# server string is the equivalent of the NT
Description field
   server string = Samba Server

In the above section you will name what Win9x/NT will identify the server as in network neighborhood. This name can be anything you want it to be, some people name it NT Server. For the sake of this tutorial unless you already have a special name for it lets leave it as Samba Server.

# This option is important for security. It allows you to restrict 
#connections to machines which are on your local network. The 
# following example restricts access to two C class networks and 
# the "loopback" interface. For more examples of the syntax see 
# the smb.conf man page   
;hosts allow = 192.168.1. 192.168.2. 127. hosts allow = 192.168.0.

The above section is very important as it deals with security issues. Most people will want access limited only to the local network. Make sure you do not leave this field empty, fill in the correct IP block for your local network.

# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this load
printers = yes

# you may wish to override the location of the printcap file
printcap name = /etc/printcap

lpq command = /usr/bin/lpq %p
lpq cache time = 30
print command = /usr/bin/lpr -P %p %s; rm %s

# on SystemV system setting printcap name to lpstat should allow
# you to automatically obtain a printer list from the SystemV spool
# system
;   printcap name = lpstat

# It should not be necessary to specify the print system type unless
# it is non-standard. Currently supported print systems include:
# bsd, sysv, plp, lprng, aix, hpux, qnx
printing = bsd

The above section deals with printing only. If you do not have a printer connected to your linux machine then you may leave all this commented out and skip to the next section. On most linux machines the above values would be correct for printing so make sure your smb.conf looks like the above.

# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
;  guest account = pcguest

The above can be a security risk for the inexperienced adminstrator so I recommend that a guest account is not used in the purpose of this tutorial. If you feel comfortable with creating such and account uncomment this field and fill in the appropriate username as your guest user account.

# this tells Samba to use a separate log file for each machine
# that connects
   log file = /usr/local/samba/var/log.%m

The above helps in debugging and logging activities of each machine that will connect to your Samba Server. I recommend that you have this field as above for future logs.

# Put a capping on the size of the log files (in Kb).
   max log size = 50

Here you can restrict the size of these log files. Pretty self explainatory.

# Security mode. Most people will want user level security. See
# security_level.txt for details.
   security = user

Well just as it says *MOST* user will want user level which is what we will be using in this tutorial so leave the security as user

# Use password server option only with security = server
;   password server =

Since we are using user level security this should remain commented out.

# Password Level allows matching of _n_ characters of the password for
# all combinations of upper and lower case.
;  password level = 8

Leave as is commented out, we will not be using this feature.

# You may wish to use password encryption. Please read
# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.
# Do not enable this option unless you have read those documents
encrypt passwords = yes

For this tutorial we will be using password encryption. There is other options as stated in the three .txt files listed above. This method is the most secure and does not require a registry edit on the Win9x/NT machine.

# Unix users can map to different SMB User names
;  username map = /etc/smbusers

This can be very beneficial to some admins with large amounts of users but for this tutorial we will not be using it.

Most people will find that this option gives better performance.
# See speed.txt and the manual pages for details
socket options = TCP_NODELAY

This does give better performance so we will be using it.

# Browser Control Options:
# set local master to no if you don't want Samba to become a master
# browser on your network. Otherwise the normal election rules apply
local master = yes

This depends on how your network is already set up and can be a real problem if you are using NT as a Domain Controller on your network already. For this tutorial we are assuming that Samba is going to be the Domain Master Browser so leave the value to yes.

# OS Level determines the precedence of this server in master browser
# elections. The default value should be reasonable
;   os level = 33

This is used to win the election between other Master Browser machines. We will leave this commented out for the tutorial as no other Master Browsers will be used within this tutorial.

# Domain Master specifies Samba to be the Domain Master Browser. This
# allows Samba to collate browse lists between subnets. Don't use this
# if you already have a Windows NT domain controller doing this job
domain master = yes

Same as local master explainations. For this tutorial we want to say yes here.

# Preferred Master causes Samba to force a local browser election on startup
# and gives it a slightly higher chance of winning the election
preferred master = yes

Leave as yes for this tutorial.

# Enable this if you want Samba to be a domain logon server for 
# Windows95 workstations. 
;   domain logons = yes

For this tutorial since we are going with just a basic setup of Samba we will leave this commented out. This is a really cool feature though and has many uses such as if you only want someone to be able to log onto the Win9x/NT machine that already has an account on the Samba Server machine.

# if you enable domain logons then you may want a per-machine or
# per user logon script
# run a specific logon batch file per workstation (machine)
;   logon script = %m.bat
# run a specific logon batch file per username
#   logon script = \\%L\%U.bat
#    logon script = \\%L\%U\%U.bat
;    logon script = %U.bat

Again since this is a tutorial of basic setup we won't be using this feature. This feature would give each user that logs on a logon script that could say map drives, etc for that particular user.

Where to store roving profiles (only for Win95 and WinNT)
#        %L substitutes for this servers netbios name, %U is username
#        You must uncomment the [Profiles] share below
;   logon path = \\%L\%U\Profiles

Once again since this is a basic setup we won't be using this. This feature is also cool as it uses Win9x roaming profiles feature.

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
   wins support = yes

For this tutorial we will be using this feature so leave it as yes

# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups. The built-in default for versions 1.9.17 is yes,
# this has been changed in version 1.9.18 to no.
   dns proxy = yes

For this tutorial we will be using this feature so leave it set as yes

# Case Preservation can be handy - system default is _no_
# NOTE: These can be set on a per share basis
;  preserve case = yes
;  short preserve case = yes
# Default case is normally upper case for all DOS files
;  default case = lower
# Be very careful with case sensitivity - it can break things!
  case sensitive = no

As this can break things lets make sure this is set to no

OK this takes care of the [GLOBAL] section of the smb.conf file. Now we will set just a couple of shares just so you can see how this works. To see the entire list of GLOBALS I use seeHERE. You can find yours when you get finished setting your shares up by doing testparm |less

#=============== Share Definitions ==============
[homes]
   comment = Home Directories
   browseable = no
   writable = yes

This is for the user that is logging in to access his/her home directory on the linux machine. Keep in mind since we are not using a GUEST account in this tutorial you will need identical user/pass on both the Win9x/NT that is also on the Linux machine.

[cdrom]
   comment = cdrom
   path = /cdrom
   readonly = yes

This will give access to your cdrom drive. In the path = line make sure it has the full path to where your cdrom is actually mounted.

[lp]
   comment = All Printers
   path = /var/spool/lpd/lp/
   browseable = no
   printable = yes      
   writable = yes
   printer = lp

If you set up printers in the [GLOBAL] section then you would need a similar share as above so others may access your printer. We will not go into actually setting up the printers in this tutorial.

There are many different features and way to set up shares in smb.conf we are only doing the very basic of examples here. There is plenty of documentation in the samba /doc directory that explains all these features.

Now your smb.conf is ready for business but we still have a few more things left to do before you are off and running. I know you are getting excited so lets at least fire up Samba and do a quick test that its working locally on the Linux machine.

  1. cd /usr/local/samba/bin
  2. nmbd -D
  3. smbd -D

This will start up Samba, you may want to put this path in your PATH to make life a lot easier on you. You can do this by adding it to your /etc/profile or ~/.profile and example in your ~/.profile might look like this:

export PATH=$PATH:/usr/local/samba/bin

You will also need to add nmbd -D and smbd -D to your startup files for bootup. I added two lines in /etc/rc.d/rc.local like this:

#Samba Is Starting Up Now echo "Samba Starting"
/usr/local/samba/bin/nmbd -D
/usr/local/samba/bin/smbd -D

Now for the quick test run

smbclient -L < your machine-name >

For example my machine name is xirtam so I run

smbclient -L xirtam

At the password prompt just hit enter. That will produce a list of your shares.

Domain=[MTXGROUP] OS=[Unix] Server=[Samba 2.0.7]

        Sharename      Type      Comment
        ---------      ----      -------
        cdrom          Disk      cdrom
        IPC$           IPC       IPC Service (xirtam  Samba Server 2.0.7)

        Server               Comment
        ---------            -------
        XIRTAM               xirtam  Samba Server 2.0.7

        Workgroup            Master
        ---------            -------
        MTXGROUP XIRTAM

OK now lets move over to the Win9x machine. I will be using a Win98 machine for this tutorial. I will be assuming you already have your Win9x machine configured for networking and on the local network. On with the show

  1. Right click on the Network Neighborhood icon and choose Properties
  2. Click on the Identification Tab and make sure the Workgroup is the same as the Workgroup field from the [GLOBAL] section in smb.conf. For this tutorial we are using WORKGROUP as the Workgroup.
  3. Click on Access Control tab and make sure Share-level is checked.
  4. Click on Configuration tab and choose Client for Microsoft Networks (If you do not have that listed then install it by clicking on Add button -> Client -> Add -> Microsoft -> Client for Microsoft Networks) Click on Properties and make sure logon and restore network connections is checked. All other things should be left blank
  5. Click on TCP/IP -> WINS Configuration tab -> Enable WINS Resolution and enter the IP address of your Samba Server.
  6. From the Configuration tab click on Add so we can add file and printer sharing. (If you already have that installed go to the next section) Add -> Service -> Microsoft -> File and printer sharing for Microsoft Networks (You will need to reboot your machine when it asks. It may also ask for your Win9X install cd or diskettes.
  7. OK should have just rebooted your machine and are now ready for the next step. Right click on Network Neighborhood icon and choose Properties, yes we are going right back to the same place we just left.
  8. Highlight File and printer shaing for Microsoft Networks -> Properties -> Browse Master should be disabled LM Announce should be No
  9. Now go into Explorer and lets share out something. Just click on any folder you would like to share out and right click on it. Choose sharing -> Share As and give your share a name, for the sake of this tutorial lets just make the share Read-Only. (Note: When you do this for real ALWAYS password protect your shares for security reasons)

Lets go back to our Samba Server Linux machine now and get the password happening.

Create the initial smbpasswd password file

  1. cat /etc/passwd | mksmbpasswd.sh > /usr/local/samba/private/smbpasswd
    Change ownership of private and smbpasswd to root.
  2. chown -R root /usr/local/samba/private
    Sets the correct permissions on /usr/local/samba/private
  3. chmod 500 /usr/local/samba/private
    Sets the correct permissions on /usr/local/samba/private/smbpasswd
  4. chmod 600 /usr/local/samba/private/smbpasswd
    Note: The mksmbpasswd.sh script is in the samba source directory.
  5. smbpasswd foo
    This will create the password for the user you will be logging into the Samba server with from your Win9X machine.

Now log into your Win9X machine with the user you just created with smbpasswd and double click on Network Neighborhood and you should see your Samba shares.

To access your Win9X shares from your Linux machine run

smbmount //machine_name/share_name /mountpoint

It will ask for your password if one is set then mount the share.

You can add it to /etc/fstab with a line like:

//machine_name/share_name /mountpoint smbfs password=your_password,noauto,rw 0 0

This should get you well on your way to using Samba. Read the documentation that comes with Samba and visit theSambasite for more information and access to the news groups.

Now that you are up and running there are a couple of neat applications you might want to grab for Samba. Go tohttp://www.littleigloo.org/downloads.php3and grap LinPopUp. LinPopUp allows you to talk to Win9X using the WinPopUp. Also you might be interested in going tohttp://www.bnro.de/~schmidjo/and grabbing LinNeighborhood. LinNeighborhood simulates NT's Network Neighborhood.

[Take me to the next sectionKernel Compiles]

Tutorial Index

Section One
Choosing and
Installing Linux

Section Two
PPP setup and
X Configurations

Section Three
IRC and Bots

Section Four
Sound and
Browsers

Section Five
inetd, ftp,
hosts files

Section Six
tar, .profile,
misc commands

Section Seven
Samba

Section Eight
Kernel Compiles

Section Nine
PHP3 / Postgres
Working Code
with Database

Section Ten
IDE-SCSI
CDR HOWTO

Section Eleven
IP Masquerading
Utilities/
IPChains

Section Twelve
Printing Tutorial

Section Thirteen
Quick overview of
Postgres install

 

ON-LINE Manuals

Apache
Full Apache Manual

PostgreSQL
Full PostgreSQL manual

PHP
Full PHP manual

Samba
Using Samba

 

Extras

Quick Reference
Listing of frequently used commands

Glossary
Glossary of terms

Man Pages
Search and View
the manpages

 
Original copyright © 1998 - 2002 K&R Information Technologies
Original Design & Graphics By: Judy
Original Content and Material By: Kimmie