Samba
Samba is an open source/free software suite that provides seamless
file and print services to Server Message Block (SMB) clients.
It allows for interoperability between Linux/Unix servers and
Windows-based clients.
Samba sets up network shares of Unix/Linux directories. These
appear to Windows users as normal Windows folders accessible via
the network.
Unix users can mount the shares directly as part of their file
structure.
How Samba Works Share on Linux
Samba Server A
B
192.168.0.253
/var/zoom
A B
/mnt/share1
Z:
Ravi Ali
Linux Client Windows Client
How Samba Works Share on Windows
Samba Server
192.168.0.253
/smb2
share
Ravi Ali
Linux Client Windows Client
Samba
Installation packages Service
samba* smb
Configuration file Daemon
/etc/samba/smb.conf nmbd
Port numbers smbd
137 NetBios Name Service
138 NetBios Datagram Service
139 NetBios Session Service
Configuration Share Folder on Linux
Samba Server
192.168.0.253
/var/zoom
/mnt/smb1
Z:
Ravi Ali
Linux Client Windows Client
Samba Server Configuration
Install the samba packages
[root@sambaserver ~]# yum install samba*
Samba Server Configuration
Create a directory to be shared
[root@sambaserver ~]# mkdir /var/zoom
Give full permissions on the directory
[root@sambaserver ~]# chmod 777 /var/zoom
Samba Server Configuration
Edit the configuration file
[root@sambaserver ~]# vi /etc/samba/smb.conf
[myshare]
comment = Zooms share
path = /var/zoom
valid users = ravi ali
public = no
writable = yes
printable = no
create mask = 0765
Samba Server Configuration
Restart the samba services
[root@sambaserver ~]# service smb restart
To test the configuration
[root@sambaserver ~]# testparm
Samba Server Configuration
Create users
[root@sambaserver ~]# useradd ravi
[root@sambaserver ~]# useradd ali
Assign samba passwords to the users
[root@sambaserver ~]# smbpasswd a ravi
[root@sambaserver ~]# smbpasswd a ali
Note:
Samba passwords are stored in /etc/samba/smbpasswd
Samba Client Configuration - Linux
Mount method to access the share
[root@client1 ~]# mkdir /mnt/smb1
[root@client1 ~]# mount //192.168.0.253/myshare
/mnt/smb1 o username=ravi
Password ********
[root@client1 ~]# cd /mnt/smb1
Samba Client Configuration - Linux
SMB client method to access the share
[root@client1 ~]# smbclient //192.168.0.253/myshare U
ravi
Password ********
smb/>
Samba Client Configuration - Windows
Map the drive
Right click My Network Places
Select Map Network Drive
In the dialog box provide
Drive: Z:
Folder: \\192.168.0.253\myshare
It opens an authentication dialog box
username : ali
password : ****
Open Windows Explorer to find Z: drive mapped to Linux
shared folder.
Configuration
Samba Server
192.168.0.253
/var/zoom
Ravi
share
Ali
Linux Client Windows Client
192.168.0.252
Shared Folder on Windows
Share the folder
Right click the folder to share
Select the option Sharing and Security
In the window select Share this folder
Provide a share name
Samba Client Configuration - Linux
Mount method to access the share
[root@comp1 ~]# mkdir /smb2
[root@comp1 ~]# mount //192.168.0.252/share /smb2 o
username=administrator
Password ********
[root@comp1 ~]# cd /smb2
Samba Client Configuration - Linux
SMB client method to access the share
[root@comp1 ~]# smbclient //192.168.0.252/share U
administrator
Password ********
Smb/>