How to Configure Samba

Samba is a Linux application that allows for sharing files, cd/dvd-rom drives and printers easily between Windows and Linux computers. You can easily set up a simple file server using Samba.

Step 1  Install Samba on your Linux computer.
  sudo apt-get install samba
Step 2  Make sure that Samba is not running.
  sudo /etc/init.d/samba stop
Step 3  Move the default configuration to a backup file.
  sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bkup
Step 4  Create a new version of smb.conf file.
  sudo gedit /etc/samba/smb.conf
Step 5  Copy this sample configuration file into smb.conf
  [global]
  workgroup = WORKGROUP
  netbios name = MYNAME
  [homes]
  comment = Home Directories
  valid users = %S
  read only = No
  browseable = No
  [shared folders]
  path = /shared_files/
  browseable = yes
  read only = no
  guest ok = no
  Each section is explained below. Remember to change the variable parameters to reflect your information.
  [global]
  workgroup = WORKGROUP
  netbios name = MYNAME
  username map = /etc/samba/smbusers
  The workgroup is the name of your Windows Workgroup. It can be found under Start -> Control Panel -> System -> Computer Name.
  The netbios name is the name of the Linux computer. It is how you browse the Linux computer from Windows.
  [homes]
  comment = Home Directories
  valid users = %S
  read only = No
  browseable = No
  Users can access their own home directories. The %S option ensures that only users must use their user name to access their files.
  [share]
  path = /shared_files/
  browseable = yes
  read only = no
  guest ok = no

The path will be the path that the client computers will be able to access. According to the rules above, you can browse the shared directory; it is not read only, and users must log in to view the directory.

Step 6  Test the smb.conf file.
  sudo testparm
Step 7  Add users to the Linux machine.
  useradd -c "New User" -m -g users -p Passwd1 newuser
  The useradd command has the syntax useradd [options] username. The example above has the following options:
  -c is the comments section which is used for the user's Full Name
  -m says to create the user's home directory
  -g is the group name for the user's initial log in group.
  -p is the user's password
Step 8  Let Samba know about the Users.
  sudo smbpasswd -a newuser
  sudo smbpasswd -e newuser
  The smbpasswd command has the syntax smbpasswd [options] username. The -a option says to add the user to the local smbpasswd file. The -e option says to enable the user.
  smbpasswd will ask you for a password. You need to supply the password that you use on the Windows machine. If you do not have a password for Windows, just press Enter.

Tips & Warnings

The default smb.conf file has detailed comments for each section. It is a good idea to read through it before creating a new one. S.W.A.T is a web based graphical interface for configuring Samba. It can be accessed by typing http://localhost:901/ in your browser's address bar.

References
The Official Samba How To
www.ehow.com

Last modified by P.Saenmuk 2010-04-30 EMail:panya@spcom.co.th http://www.spcom.co.th เอสพี.คอมพิวเตอร์ เทคโนโลยี