Loading...
Advance Linux

Samba Server

Samba using smb protocol. It also called as “Server Message Block” also known as “netbios/tcp-ip

Features of SAMBA:

  1. File/Directory Sharing
  2. Browsing
  3. Resource Sharing
  4. Using authentication and Authorization

Requirments:

Packages : Samba* …. rpm
port no : 137 – Net BIOS name service.
138 – Net BIOS Datagram Service.
139 -Net BIOS Session Service
config File : /etc/Samba/smb.conf
service : smb
Daemons : smbd (Server message block daemon)
nmbd (net BIOS naming daemon)

Configure SAMBA Server:
Before configuring the Samba Server, First we check the Samba Server is installed or not

#rmp   -qa   |   grep   -i     Samba

Note: If it is not installed, then it will not show any output. If the Samba Server Software is installed in the machine, it will show you the output as

# rmp    -qa   |   grep   -i   Samba
Samba -.0.33

1) Samba server helps to provide a common area for data or user directories to transition from a Windows server to a linux/Unix one, or vice versa.
2) SAMBA SHARE provides access to group of users who have a mixture of Windows and Linux/Unix computers.
3) Samba Supports CIFS(Common Internet File System)
4) Samba is an authentication based service.
5) Samba uses Port Number 445,139.

Server Side Configuration :

To Install SAMBA packages and their dependencies in SAMBA Server use below commands

yum install samba* 
rpm -qa samba*  

OR

yum install samba samba-client samba-common

Start the samba service with below commands

systemctl start smb
systemctl start nmb
systemctl enable smb
systemctl enable nmb

To allow samba service through firewall

firewall-cmd --permanent --add-service=samba
firewall-cmd --reload

Create Samba Group to add all samba users to it as below

 groupadd smbgrp 

To create Samba user and assign password to it

useradd user1 -s /sbin/nologin -G smbgrp
tail /etc/passwd
smbpasswd -a user1

Create a samba folder as below

mkdir /samba
cd /samba 

In that create folders which you want share with others

mkdir LinuxTraining 

It would be like below path

/samba/LinuxTraining

And give required permissions to path

chown -R user1:smbgrp /samba/LinuxTraining
chmod -R 770 /samba/LinuxTraining

Samba configuration File :

vi /etc/samba/smb.conf 
[LinuxTraining]
 path = /samba/LinuxTraining
 guest ok = no
 browseable= yes
 writable = yes
 browsable = yes
 write list = user1,user2
 read list = user3,user4
 valid users= user1,user2,user3,user4
 case sensitive = yes
 preserve case = yes
 short preserve case = yes
 default case = upper 

After adding above lines in configuration file restart the services

systemctl restart smb
systemctl restart nmb
Client Side Configuration :

To access samba server files from any client location there are different ways , Some of them are

Type 1 : Files To Acess From LINUX Client TO LINUX Server

In Centos 7

yum install samba-client

In ubuntu

apt-get install smbclient

Syntax To access samba share as below

smbclient //SambaServerIP/LinuxHosting -U username 
Example : smbclient //10.10.10.111/Linuxhosting -U user1
Type 2 : Files To Acess From Windows Client TO LINUX Server
Enter Ctrl + R (windows Run)

\\10.10.10.111\sharefoldername

Enter Workgroup Name : WorkGroup
Enter username : 
Enter password : 
Type 3 : Files To Acess From LINUX GUI MACHINE TO LINUX Server

In ubuntu Go to Connect server and enter as below

smb://10.10.10.111/sharefoldername
Enter Workgroup
Enter username
Enter password
Mount a NFS Share on Local Folder

Install cifs utils in client system

yum install cifs-utils

Create a local directory to mount samba share folder on it.

mkdir /mnt/LocalSAMBA
mount -t cifs -o username=user1 //SambaServerIP/LinuxTraining   /mnt/LocalSAMBA

It will ask password of samba user user1 so enter the password and access the files

password for user1@SAMBAServerIP/LinuxTraining :  *******

Leave a Reply

Your email address will not be published. Required fields are marked *