The aim of this QND guide is to get you up and running quickly with samba. There will be far more how than why here.
This guide is aimed towards the home networker who wants to use his Linux or FreeBSD box as a file server. This article only covers setting up the *nix box so that files can be shared from it.
Because of the many differences in which each distribution and FreeBSD handle samba, we are making a few assumptions here. We are assuming that you understand your machine's firewall and how to allow a new port to go through it. We are assuming that you know how to start a service on bootup. If you don't know how to start a service at bootup, then check out our QND guide on running a program when the machine boots. In Samba's case, although some distros will start both daemons with a samba command the two daemons you want are the smbd and nmbd ones.
A great many things can go wrong with samba. This guide is making the assumption that they won't. :) However, there will be some links at the end, to more involved documentation and troubleshooting pages.
In a command shell type
This must be done as root. It won't work with sudo nor will it work with a simple su. It will, however, work with su -. This should return the path to the two programs, probably /usr/sbin/. (In FreeBSD probably /usr/local/sbin/). If it finds it, go to step 3. If it doesn't go to step 2.
Go to the QND software guide for information about getting and installing . We'll wait. If it turns out that is not included with your particular flavor of Linux then try their home page which has rpms and source code.
Firstly, find your /etc/smb.conf. This will vary upon O/S and distro. Usually, there will be an /etc/smb.conf or /etc/samba/smb.conf. In FreeBSD it will be in /usr/local/etc. (It might only be in /userports/net/samba/work/samba-versionnumber/examples/sample) There may only be a file called something like smb.conf.sample. If that's the case, copy the file to smb.conf
|cp smb.conf.sample smb.conf|
and you will have a file to edit.
In the top section, [global] you'll find a line
|workgroup = MYGROUP|
Change this to the name of your workgroup or domain. In MS, the default name is WORKGROUP. (Gentoo Linux actually has this name as WORKGROUP by default.) You may also choose to rename your MS machines to MYGROUP--the point here is that they have to have the same name.
Next look for a line saying
|;encrypt passwords = yes|
Again, Gentoo has this uncommented. If it's commented by the ; in your smb.conf, uncomment it unless you're running Windows 95 or Windows 98 pre-second edition.
In samba 3.x this is no longer necessary, it works with encrypted passwords by default.
For purposes of example, we're going to assume that you have a user named john on the MS box with a password of 1234. So, now add that user name to your Linux or FreeBSD box. As there are various commands to do this, and they vary with distribution, hopefully, it is something that you already know how to do. For example, in Gentoo it would be
|useradd -m -s /bin/bash john|
You can give him a password or not, depending upon your needs, distribution, etc. Again using Gentoo as an example, if he has no password, he won't be able to log into the Linux box--other distros might allow him to log in with a blank password, in which case, you obviously want to give him a password. Now, we have to add john to the smbpasswd file
|smbpasswd -a john|
It will ask for the new password and then ask you to type it again. This password has to be the same as it is for user john on the MS box.
Note that in samba 3.x smbpasswd is deprecated. It is suggested that you use tdbsam. Rather than smbpasswd -a john the syntax is
pdbedit -a -u john
One other important point--many distributions, such as RedHat, have a default firewall that will block samba. Firewalls are beyond the scope of this QND guide, but if you are using RedHat, you can use their builtin lokkit to allow samba to work. Regardless of distro, you have to allow both tcp and udp on ports 137:139.
Now we can start samba--again, this depends very much upon distro--in Gentoo it's
To have it run at boot
|rc-update add samba default|
With RedHat, you can use their ntsysv or chkconfig. You may have to start both smbd and nmbd, or their later configurations might simply have a samba command. In FreeBSD it will place a script in /usr/local/etc/rc.d. However, comments in the script indicate that you have to add to /etc/rc.conf
Again, hopefully, you already know how to start services at boot in your distro of choice. To simply start it for testing, a simple
will usually be sufficient. (If it's somewhere else, such as FreeBSD's /usr/local/sbin, then of course, use that path name)
Firstly, at a command prompt, type
This simply tests for any grievious syntax errors. Hopefully, it won't show any. Now fire up the Windows box. Log on as user john with the password of 1234. Open up Network Neighborhood or My Network Places and see if you can find the samba box. If so, there should be a folder for the user john. If you can put a text document in there and save it, you have been successful.
Congratulations, you should be done.
However, as mentioned before, many things can go wrong with Samba. If you aren't able to read or write to john's folder on the Linux box, you can try my samba page which goes into more detail. That page also has links to the online O'Reilly guide.
There is usually a trouble shooting guide in the samba docs that are included with the program. In FreeBSD-5.3, they're in /usr/local/share/doc/samba. (The troubleshooting one is in the Samba-HOWTO-Collection.pdf, in a section called, interestingly enough, Trouble Shooting.) :)
samba home page