How To: Samba Setup
This how-to assumes the following: You use the same login name on your Windows and Linux computers. You are using Static IP's behind your router. You can use a text editor (Nano, Kate, emacs, vi, gedit, or whichever text editor you like).
Written by Clinton Messer
Basically, you need to do the following:
- Install Samba packages
- Create your smb password for your account
- Create/Modify the smbusers file
- Modify the smb.conf file to enter the information for your users and the shared drives they will access.
- Start the Samba Server
The process is really simple; it's just somewhat tedious.
First off, install your samba packages using Adept, Synaptic or apt-get. Kubuntu 6.10 comes with the package “samba-common” installed by default, but SAMBA is neither fully installed nor set up, so you need to grab the packages.
Installing the packages
- samba
- samba-doc
(samba-doc means you can learn the finer points of tuning a SAMBA setup)
These additional packages may or may not be needed, but I installed them anyway:
- komba2
- smb4k
- swat
Create/Set the smb password
Then, you need to set your user's smb password to be the same between windows and linux by performing the following command at the command line (Terminal window)
sudo smbpasswd -a bob
Then, enter your password.
In the example above, bob is the person logged in and entering the command on the machine called bob-samba.
By running the command above, bob will get prompted to create a password for a user named bob. This username should be the same login name you use to access your Windows and Linux boxes.
Create/Modify the smbusers file
Once you've set the smb password, you need to either modify or create the smbusers file
sudo nano /etc/samba/smbusers
Then, enter your password.
In the smbusers file, modify/add the following line:
USERNAME = "network username"
USERNAME = the name you are going to use to log into the machine with. Using bob as an example, it would look like:
bob = "network username"
Save the file in your text editor and exit the editor.
Modify the smb.configuration
file
sudo nano /etc/samba/smb.conf
Then, enter your password.
You can use whatever editor. I use nano since it's present in both Kubuntu and Ubuntu.
In the smb.conf
file, make the following additions:
Locate the section titled
[global]
If the following entries do not exist, add them. If they do exist and are set to something else, modify them to read:
workgroup = MSHOME
Enter your workgroup's name here in place of MSHOME.
netbios name = bob-samba
Enter the HostName here of your *buntu box.
Scroll down to locate the following entry:
; security = user
Remove the semi-colon ( ; ) from the entry above and add the following line directly below it
username map = /etc/samba/smbusers
Scroll down to the section
==== Share Definitions ===
in that section, locate the entry labeled
[printers]
After the last entry for printers, enter the information for your shares.
I place my shared drive entries after the printer section because it works for me but you can put them anywhere in the Share Definitions section
I named each of my shares in the smb.conf
file to match the name of the drive as it appears in the /media/
folder. I recommend using this method for the sake of simplicity.
You can copy and paste the following entries if you want. Just be sure to modify them to reflect your drive names and user names
# My Shared Folders
[DRIVE1]
path = /media/DRIVE1/
browseable = yes
read only = no*guest ok = no
create mask = 0644
directory mask = 0755
force user = USERNAME
force group = USERNAME
[DRIVE2]
path = /media/DRIVE2/
browseable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
force user = USERNAME
force group = USERNAME
In place of the "USERNAME" entries above, make sure USERNAME is set to the same username you use to log into the system on both Windows and Linux
The group name should be set to the groupname your Linux login name is set to.
Once all these steps are complete, you can try starting up Samba and accessing the shares.
sudo testparm
Then, enter your password.
Then restart Samba
sudo /etc/init.d/samba restart
Then, enter your password.
You should now be able to browse the network from your windows machines and see/access/read/write to your shared Linux Drives.