To study Samba as an open source project for sharing
Samba
(Server Message Block Protocol )
Aim:
To study Samba as an open source project for sharing
Theory:
Samba on Linux is something completely different. Samba is an implementation of a Server Message Block (SMB) protocol server that can be run on almost every variant of UNIX in existence. Samba is an open source project, just like Linux. The entire code is written in C so it is easily portable to all flavors of UNIX. Samba is a tool for the peaceful coexistence of UNIX and Windows on the same network on the level of File and Print sharing over the NetBIOS protocol. It allows UNIX systems to move into a Windows “Network Neighborhood” without causing a mess. With Samba, UNIX servers are acting as any other Windows server, offering its resources to the SMB clients.
When the Samba package is installed, a default configuration file is installed in: etc/smb.conf
Creating shares
A simple share can be defined in the smb.conf file as follows:
[redbook]
comment = Redbook files
path = /redbook
browseable = yes
printable = no
writable = yes
write list = @users
Share permissions:
Although we can control the share permissions with share parameters, UNIX permissions are applied before share permissions. Make sure the UNIX permissions let the users access the share directory in the UNIX environment. When a user creates a new file on the shared directory, the default create mask used is 0744. For directory creation, the default create mask is 0755.
Creating shares for home directories
For handling home directories smb.conf has a special share section called [homes]. This share definition is used for all home directories, so we don’t need to create separate shares for each user. When a client requests a connection to a share, existing shares are scanned. If a match is found, that share is used. If no match is found, the requested share is treated as the username and validated by security. If the name exists and the
password is correct, a share with that name is created by cloning the [homes]
section. Home share definitions use the same parameters as normal shares. The
following is an example of a [homes] share definition in the smb.conf file:
[homes]
comment = Home Directories
path = %H
valid users = %S
browseable = no
writable = yes
create mode = 0700
directory mode = 0700
Parameter Description
%H This variable represents the home directory of the user.
%S The name of the current service, which is in the case of [home]
shares equal to username.
Creating a printer share
A Samba server uses the same procedure for [printer] shares as for [home] shares. The share definitions and user names are tested against the requested share name. If a match is found in the [printers] share section, a share with that name is cloned with the name of the requested service. The following is an example of a [printers] definition in the smb.conf file:
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
# Set public = yes to allow user ’guest account’ to print
guest ok = no
writable = no
printable = yes
create mask = 0700
.
Starting and stopping the Samba server
One can start the Samba server by executing the following
command:
/etc/rc.d/init.d/smb start
You will see:
Starting SMB services:
Starting NMB services:
Two daemons are started: smbd and nmbd. smbd is the Samba server and nmbd is the WINS server. The Samba server can be stopped by executing the command:
/etc/rc.d/init.d/smb stop
Whenever you modify the smb.conf configuration file you must restart the Samba server.
Creating a new share
1. Create the directory that will be used for the share. You can do this by
executing the command:
mkdir /home/public
2. Make sure that UNIX permissions are set correctly in the directory so that only
intended users have access rights to it.
Restarting the Samba server
To restart the Samba server, click the Status icon. Click Restart smbd. On this page you can also restart the WINS server by clicking Restart nmbd.
Conclusion:
Thus we have studied Samba, an implementation of a server message block protocol.
Leave a Reply