titan386
11-12-2002, 03:29 PM
I've also posted this on the OC forums, but I figured you guys could use it too:
For those who don't know, samba is a program designed to allow *nix to serve windows file and printer shares.
I'm not going to cover installion of samba, mainly because most distros install it by default.
The first thing you need to do, assuming you have samba correctly installed, is to locate your smb.conf file. Generally, this is located in /etc/samba/. If you can't find it there, this is how you can locate it:
as root, run:
slocate -u
this will build a database of the files on your system, and will take a while. After its done, run:
slocate smb.conf
and it will tell you where to find it.
Samba, like many unix programs, its configured via a text file, in this case, smb.conf. To change the way the samba server behaves, you change this file.
Before we actually get start configuring samba, we must do some preparation for the system. First, let's create a user that samba can run under. First, make the user with the useradd command, like so: (as root of course)
useradd -m username
The m arguement tells the system to build a home directory for our new user, at /home/username. This is generally a good idea, but its up to you.
We will set a samba password for our new user, but that requires the samba server to be running, so we'll wait on that for a little while. Note that this is different from a regular user password.
The username should be the same as the username of the windows computer you want to share with. You can also make a share public, and available to all users, but we will deal with that later.
Finally, its a good idea to change your hostname from something other than the default, 'localhost', before we go any further. It seems that trying to connect to a machine named localhost confuses some windows machines (I believe those running windows XP). To change it, place a file name HOSTNAME in the /etc/ directory, and using your favorite text editor, type the hostname and domain of your choice with the following syntax:
hostname.domainname
For the purposes of this, will use use pico because the interface is easy to understand, unlike vi or emacs. Type the following at a command promt:
pico /etc/HOSTNAME
and simply type the hostname and domain of your choice in the format above. When your done, hit ctrl x, y and enter a few times to confirm and save the file. Then reboot the machine, and check that your hostname is what you selected. You should be able to see it after your username at the bash promt.
Now we're ready to jump into smb.conf. The basic format of smb.conf consisted of keys, all under groups. It looks like this:
[group]
key = value
Pretty straightforward. A very basic smb.conf looks like this:
workgroup = yourworkgroup
[homes]
guest ok = no
read only = no
This brings up something very important: workgroup. If you workgroup is not exactly the same for all computers you want to have access to, none of this will work when you try to access it from your windows box.
Change into your samba directory (cd /etc/samba or whatever your directory is) and use pico to create that smb.conf file for now. If you have a samble smb.conf file, rename it so you can use it later (do it like so: mv smb.conf smb.sample.conf). Now, lets test our samba configuration.
Let's test our smb.conf syntax first. Type testparm and look at what it returns. If there are any errors it will tell you and you must fix them before continueing.
For those who don't know, samba is a program designed to allow *nix to serve windows file and printer shares.
I'm not going to cover installion of samba, mainly because most distros install it by default.
The first thing you need to do, assuming you have samba correctly installed, is to locate your smb.conf file. Generally, this is located in /etc/samba/. If you can't find it there, this is how you can locate it:
as root, run:
slocate -u
this will build a database of the files on your system, and will take a while. After its done, run:
slocate smb.conf
and it will tell you where to find it.
Samba, like many unix programs, its configured via a text file, in this case, smb.conf. To change the way the samba server behaves, you change this file.
Before we actually get start configuring samba, we must do some preparation for the system. First, let's create a user that samba can run under. First, make the user with the useradd command, like so: (as root of course)
useradd -m username
The m arguement tells the system to build a home directory for our new user, at /home/username. This is generally a good idea, but its up to you.
We will set a samba password for our new user, but that requires the samba server to be running, so we'll wait on that for a little while. Note that this is different from a regular user password.
The username should be the same as the username of the windows computer you want to share with. You can also make a share public, and available to all users, but we will deal with that later.
Finally, its a good idea to change your hostname from something other than the default, 'localhost', before we go any further. It seems that trying to connect to a machine named localhost confuses some windows machines (I believe those running windows XP). To change it, place a file name HOSTNAME in the /etc/ directory, and using your favorite text editor, type the hostname and domain of your choice with the following syntax:
hostname.domainname
For the purposes of this, will use use pico because the interface is easy to understand, unlike vi or emacs. Type the following at a command promt:
pico /etc/HOSTNAME
and simply type the hostname and domain of your choice in the format above. When your done, hit ctrl x, y and enter a few times to confirm and save the file. Then reboot the machine, and check that your hostname is what you selected. You should be able to see it after your username at the bash promt.
Now we're ready to jump into smb.conf. The basic format of smb.conf consisted of keys, all under groups. It looks like this:
[group]
key = value
Pretty straightforward. A very basic smb.conf looks like this:
workgroup = yourworkgroup
[homes]
guest ok = no
read only = no
This brings up something very important: workgroup. If you workgroup is not exactly the same for all computers you want to have access to, none of this will work when you try to access it from your windows box.
Change into your samba directory (cd /etc/samba or whatever your directory is) and use pico to create that smb.conf file for now. If you have a samble smb.conf file, rename it so you can use it later (do it like so: mv smb.conf smb.sample.conf). Now, lets test our samba configuration.
Let's test our smb.conf syntax first. Type testparm and look at what it returns. If there are any errors it will tell you and you must fix them before continueing.