Quick and Dirty Samba Installation

Samba is a GPL-licensed software package that allows for directories on Linux/Unix machines to be mounted on a Windows network. While there is a significant body of literature already available on this package, none of it seems to be able to explain the setup process to someone who isn't already familiar with the software. The goal of this document is to get a basic Samba installation up and running so that it later becomes possible to take advantage of the rich set of features provided by this software.

Downloading and Installing

The source code for Samba is available at the project's website. The filename for the latest stable version is almost always samba-latest.tar.gz As with all other Unix packages, it is strongly recommended that the latest version of the software be used. The build process is similar to other Unix software. First, download the package into a temporary directory, then enter the commands below. Each command is followed with a brief explanation as to what the command does.

Command Explanation
tar -zxf samba-latest.tar.gz Unzips and untars the Samba source code in one step. This filename may vary if you are using a specific version of Samba instead of the latest version.
cd samba-version_number/source Changes to the directory containing the source code.

Use either tab auto-complete or the ls command to get the version number.
./configure --with-smbmount Sets up compile/build process so that the Linux box onto which this software is installed will also be able to mount other Windows (and Samba) shares, in addition to being able to have its own directories mounted by other machines.
make Compiles the source code and builds the binaries.
make install Installs the compiled binaries into the appropriate directories. This must be done as root.

Post-Install Configuration

Once these tasks are complete, you need to create a configuration file which will tell Samba how to operate. While logged in as root and with your favorite text editor, create a file called smb.conf in the path /usr/local/samba/lib. Unless you specified additional parameters in the steps above, this path and filename are where Samba expects to find this information. In this file, enter the following text. You will most likely need to alter this somewhat to fit your environment:

[global]
      workgroup = Your_Workgroup_or_Domain
      netbios name = Name_Of_Machine_As_It_Appears_In_Network_Neighborhood
      encrypt passwords = yes
      invalid users = root @wheel
      local master = no
      domain master = no
      log file = /usr/local/samba/var/%m.log
      log level = 1
      server string = Machine's Description as it appears in Network Neighborhood

[homes]
      readonly = no

The configuration file supports free-form text. Indentation was used in this file to emphasize the hierarchy that Samba uses when directives are processed. Save the file and close the editor. You can ensure that your configuration file is syntactically correct by executing the command below:

/usr/local/samba/bin/testparm

This command also shows all the other available options you could put in this file. If you did not specify a given option, its default value is used. The default values are also listed when you execute testparm. The Samba options used above are explained below:

Option Explanation
[global] The "global" section heading. All section headings are enclosed in square brackets. Any option under the global heading applies to the Samba installation in its entirety. Any option under any other heading applies only to that heading. Section headings not named "global" typically apply to each shared directory you want to make available on the Linux box.
workgroup = Your_Workgroup_or_Domain The name of the Windows workgroup or Domain that this machine should belong to.
netbios name = Name_Of_Machine_As_It_ ... The name of the machine as you want it to appear in the "Network Neighborhood."
encrypt passwords = yes This option must be present or else you will not be able to connect from any Windows machines. Encrypted passwords for network access are required in Windows 98 and higher.
invalid users = root @wheel Userids which will be denied access if they try to mount a share on this machine. Naturally, we want any administrative user account included here, hence the inclusion of root. The "@wheel" option indicates that no user who is a member of the "wheel" group will be allowed to mount shares.
local master = no
domain master = no
As this machine is not being set up to be a domain controller, but just a client machine on the Windows network, setting these options to "No" will ensure that this machine doesn't interfere with the operations of existing Windows Active Directory Controllers, PDCs, BDCs, etc.
log file = /usr/local/samba/var/%m.log
log level = 1
These parameters are optional. Logs connections from each machine in same directory as main Samba logs and enables basic logging.
server string = Machine's Description ... This parameter is optional. This is what gets listed as a comment for your machine when your browse the network.
[homes] This heading describes how users' home directories will be handled.
readonly = no Permits users to write to their home directories.

After all this is done, the smbpasswd utility must be used to create the account/password list of users who will be allowed to connect. These accounts have no connection to the userids and passwords that local users use to connect to the machine through telnet, ssh and ftp, etc. However, for the sake of convenience, you should use the same userid and password combinations that already exist. To add a user called "phil", for example, you would use the following command:

/usr/local/samba/bin/smbpasswd -a phil

You will then be prompted for a Samba password, and then asked to confirm it. Once this is done, you will be ready to start the Samba services and then connect to the Linux box from Windows machines. Two commands are required. As root, enter the following:

/usr/local/samba/sbin/smbd -D
/usr/local/samba/sbin/nmbd -D

These commands start the Samba services in "daemon" mode. You can also include these commands in the startup file for the Linux box, /etc/rc.local. Now go to a Windows machine, open an explorer window, and type in the address bar "\\" and then the IP address of the Linux box. You should be prompted for a userid and password. Enter the Samba userid and password you created above and you should then be able to see and access your home directory. It may also possible to see this name in the "Network Neighborhood" from a Windows machine.

Disclaimer

I never was nor will I ever claim to be a networking expert. This document was the result of a lot of trial and error on my part to get a very basic installation of Samba working under Linux. There's a lot more to Samba and what it can do and I strongly encourage you to visit its website to find out more information.


Back to Stupid Networking Tricks philatfacebook@gmail.com

Valid HTML 4.01 Transitional