Samba

Introduction
Samba is software that can be run on a platform other than Microsoft Windows, for example, UNIX, Linux, IBM System 390, OpenVMS, and other operating systems. Samba uses the TCP/IP protocol that is installed on the host server. When correctly configured, it allows that host to interact with a Microsoft Windows client or server as if it is a Windows file and print server.

Links

 * Samba Official Website
 * Samba by Examples
 * Samba - "How To" Collection
 * Examples of many configuration for Samba

Starting the samba Daemon
Use the command:

$ /usr/sbin/smbd -D -s /etc/samba/smb.conf

Sharing Directories
To share a linux directory with windows users, edit the file. For example, to create a share directory under with the name temp insert the piece of code bellow into your  file.

[temp] comment = Müll 100%. Nur für Daten-Austausch ! :-)	path = /shared	read only = no	public = yes       writable = yes

To protect a directory with the samba password you have to add an existing linux user to the file using the following command:

smbpasswd -a

The system requests a password for the user.

After this, you can add a new entry into the file like this:

[jaraujo] comment = Linux shared folder by Joao. path = / read only = no	public = no	writable = yes valid users = jaraujo

You can separate many users using commas for each user in the entry valid users. Example: valid users = jaraujo, tomcat.

In this case it is better to ensure that Samba encrypts the password on the fly. Insert the following line in the [Global] section:

encrypt passwords = yes

Example of configuration file
The Samba configuration file can be found at. The example below enables the folder called Geral to be public and writable. The other folders like Livinha, Joca and Angela are not visible (not browseable) and are protected using password.

[global] workgroup = Pedras netbios name = Topazio comment = Servidor de arquivos Topazio # smbstatus will output various info on current status status = yes browseable = yes printing = bsd # the username that will be used for access to services # specified with 'guest = ok' guest account = geral # avoid printer wizards show add printer wizard = No # - # [globals] Security and Domain Logon Services # -	 # connections are made with UID and GID, not as shares security = SHARE # boolean variable that controls whether passwords # will be encrypted encrypt passwords = yes # --- # [globals] Performance Tuning # --- 	# caching algorithm to reduce time doing getwd calls. getwd cache = yes socket options = TCP_NODELAY # tell the server whether the client is present and # responding in seconds keep alive = 60 # num minutes of inactivity before a connection is 	# considered dead dead time = 30 read prediction = yes share modes = yes max xmit = 17384 read size = 512 # locking is done by the server locking = yes # control whether dos style attributes should be mapped # to unix execute bits map hidden = yes map archive = yes map system = yes [geral] comment = Arquivos gerais como músicas, vídeos, softwares, livros, fotos, imagens, etc. 	path = /local/geral/ read only = No 	public = Yes guest ok = yes force user = geral force group = users [joca] comment = Arquivos de Joca path = /local/joca/ read only = No 	public = No 	browseable = No 	valid users = joca [livinha] comment = Arquivos de Livinha path = /local/livinha/ read only = No 	public = No 	browseable = No 	valid users = livinha [angela] comment = Arquivos de Angela path = /local/angela/ read only = No 	public = No 	browseable = No 	valid users = angela

Scanning resources on remote computers
Use the command:

$ smbclient -L

If a user is needed use the option -U. For example:

$ smbclient -L Myserver -U myuser

Mounting shared directories
Create a mounting point in your computer which will be linked to the remote shared directory. Example:

$ md /mnt/projekte

Mount the shared dicretory:

$ mount -t smbfs   -o username= password=

Example:

$ mount -t smbfs //myserver/Projects /mnt/projects -o username=myuser

You can also try to use the command smbmount:

$ smbmount //myserver/Projects /mnt/projects -o username=myuser

Automatic mount at startup
Edit the file and add the shared resources to be mounted:

//myserver/projekte /mnt/projekte     smbfs      username= ,password= ,file_mode=0777,dir_mode=0777 //backup/daten /mnt/backup            smbfs     file_mode=0777,dir_mode=0777


 * file_mode=
 * sets the file mask. This determines the permissions that remote files have in the  local filesystem. This is not a umask, but the actual permissions              for the files. The default is based on the current umask.


 * dir_mode=
 * Sets the directory mask. This determines the permissions that remote  directories have in the local filesystem. This is not a umask, but the actu              al permissions for the directories. The default is based  on  the  current umask.