You are on page 1of 24

SAMBA PROROCOL:

What is Samba ?

 It is mainly used for file sharing between two different Operating System.

For eg,

Linux – Windows

Windows – Linux

Advantage:

 Two way Sharing:

File sharing on Server to Client and Client to Server

--------------------------------------------------------------------------------------------

How to use Samba protocol used for Linux?

Server machine steps: Linux Operating System

1. Set IP address for server machine


2. Create Repository
3. Install ‘Samba’ Package: samba ,samba-client
4. To create directory for Samba link
5. To give permissions for Samba link Directory
6. Samba Server Configuration :/etc/samba/smb.conf
7. Add Label value for Samba link Directory
8. Set user name and Password for Samba Account (its used for client access the
Server Host to give Username and Password)
9. Service :enable Samba service (smb,nmb) on Server machine
10.Firewall :add Samba(Samba) Service on Firewal

Client machine steps: Windows Operating System

1. Set IP address for client machine


2. Open Run Cmd: \\Server IP address

 To take Linux Machine ( Server)

Step 1:Set IP address for server(Linux machine):

-------------------------------------------------------------------------

Syntax : [root@localhost /]# <nmtui>

Cmd : [root@localhost /]# nmtui

Select -> Edit and connection


Select ->Ethernet(eno) and Edit

Select ->IPv4 CONFIGURATION, and Change <Automatic> to <Manual>


Select -> <Show> IPv4 CONFIGURATION and Assign IP Addresses , Gateway,
DNS Servers and OK

Select -> Quit

-----------------------------------------------------------------------------------------------
How to activate IP Address?

Syntax : [root@localhost /]# <nmtui>

Cmd : [root@localhost /]# nmtui

Select -> Activate a connection

Select ->PCI Ethernet( *eno) and select <Deactivate> again <Activate>


Select -> Quit

How to check IP address ?

Syntax :[root@localhost /]# <ifconfig>

Cmd :[root@localhost /]# ifconfig

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 10.0.0.10 netmask 255.255.255.0 broadcast 10.0.0.255

 This line indicates for IP address, net mask

-----------------------------------------------------------------------------------------------
Step 2 :Create Repository

-----------------------------------------------------------------------------------------------

 First you have extract Packages from OS to Linux Workstation


 You have change mount location for Packages
 Create Repository
 Clear Repository caches
 To check repolist

How to extract Packages from OS to Linux Workstation?

Step 1:

 Right click ->Virtual Machine Name -> Settings ->CD/DVD(SATA)-> Use ISO
File image ->Browse OS File Location ->Open -> OK

Step 2 :

Right click ->Removable Device ->CD/DVD(SATA) -> Connect

How to mount Packages?

 Default Packages are mounted this location /run/media/root/RHEL-7.2


Server.x86_64

[root@localhost Desktop]# cd /

[root@localhost /]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 20G 0 disk

├─sda1 8:1 0 1G 0 part /boot


└─sda2 8:2 0 19G 0 part

├─rhel-root 253:0 0 15G 0 lvm /

└─rhel-swap 253:1 0 4G 0 lvm [SWAP]

sdb 8:16 0 5G 0 disk

└─sdb1 8:17 0 5G 0 part [SWAP]

sdc 8:32 0 5G 0 disk

└─sdc1 8:33 0 5G 0 part /quota

sr0 11:0 1 3.8G 0 rom /run/media/root/RHEL-7.2 Server.x86_64

------------------------------------------------------------------------------------------------

sr0 11:0 1 3.8G 0 rom /run/media/root/RHEL-7.2 Server.x86_64

 This line indicates for cd rom or OS size , and mounting location

------------------------------------------------------------------------------------------------

How to change mounting location?

Syntax:[root@localhost /]#< mount>space </dev/cdrom>space </mounting directory


name>

Cmd :[root@localhost /]# mount /dev/cdrom /mnt

mount: /dev/sr0 is write-protected, mounting read-only

------------------------------------------------------------------------------------------------

How to create Repository?

Syntax:[root@karthikeyaa /]#< vim>space </etc/yum.repos.d/


any name.repo>

Cmd :[root@karthikeyaa /]# vim /etc/yum.repos.d/karthi.repo

Go to “INSERT” Mode and Enter:

[1]

name=test

baseurl=file:///mnt

enabled=1

gpgcheck=0

Esc :wq

------------------------------------------------------------------------------------------------

How to clear repository caches?

Syntax: [root@karthikeyaa /]# <yum>space< clean>space< all>

Cmd: [root@karthikeyaa /]# yum clean all

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-

: manager

This system is not registered to Red Hat Subscription Management. You can use
subscription-manager to register.

Cleaning repos: 1
Cleaning up everything

------------------------------------------------------------------------------------------------

How to check repository file list complete information?

Syntax: [root@karthikeyaa /]# <yum>space <repolist>

Cmd: [root@karthikeyaa /]# yum repolist

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-

: manager

This system is not registered to Red Hat Subscription Management. You can use
subscription-manager to register.

1 | 4.1 kB 00:00

(1/2): 1/group_gz | 136 kB 00:00

(2/2): 1/primary_db | 3.6 MB 00:00

repo id repo name status

1 test 4,620

Step 3: Install Samba Package: samba, samba-client

-----------------------------------------------------------------------------------------------

How to install Samba package (samba, samba-client)?

Syntax : [root@karthikeyaa Packages]#< yum>space< install>space <installing


package name> space <-y>
1st Package Cmd : [root@localhost /]# yum install samba -y

Loaded plugins: langpacks, product-id, search-disabled-repos,

: subscription-manager

This system is not registered to Red Hat Subscription Management. You can use
subscription-manager to register.

Resolving Dependencies

--> Running transaction check

---> Package samba.x86_64 0:4.2.3-10.el7 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

===============================================================
=======

Package Arch Version Repository

Size

===============================================================
=======

Installing:

samba x86_64 4.2.3-10.el7 1 601 k


Transaction Summary

===============================================================
=======

Install 1 Package

Total download size: 601 k

Installed size: 1.8 M

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Installing : samba-4.2.3-10.el7.x86_64 1/1

Verifying : samba-4.2.3-10.el7.x86_64 1/1

Installed:

samba.x86_64 0:4.2.3-10.el7

Complete!

--------------------------------------------------------------------------------------------

2nd Package Cmd: [root@localhost /]# yum install samba-client -y


Loaded plugins: langpacks, product-id, search-disabled-repos,

: subscription-manager

This system is not registered to Red Hat Subscription Management. You can use
subscription-manager to register.

Resolving Dependencies

--> Running transaction check

---> Package samba-client.x86_64 0:4.2.3-10.el7 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

===============================================================
=======

Package Arch Version Repository

Size

===============================================================
=======

Installing:

samba-client x86_64 4.2.3-10.el7 1 496 k

Transaction Summary
===============================================================
=======

Install 1 Package

Total download size: 496 k

Installed size: 1.3 M

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Installing : samba-client-4.2.3-10.el7.x86_64 1/1

Verifying : samba-client-4.2.3-10.el7.x86_64 1/1

Installed:

samba-client.x86_64 0:4.2.3-10.el7

Complete!

------------------------------------------------------------------------------------------------

Step 4 : To create Samba link directory

Syntax : [root@localhost /]# <mkdir> space </Samba link directory name>


Cmd : [root@localhost /]# mkdir Samba_dir

-----------------------------------------------------------------------------------------------

Step 5:To give permissions for Samba link Directory

Syntax : [root@localhost /]# <chmod > space <777>space </Samba link directory
name>

Cmd : [root@localhost /]# chmod 777 /Samba_dir

------------------------------------------------------------------------------------

Step 6 : Samba Server Configuration :/etc/samba/smb.conf

How toSamba link created on Server to Client Specified network?

 Samba configuration files are Default location in /etc/samba/smb.conf

Syntax : [root@localhost /]# <vim> space </etc/samba/smb.conf>

Cmd : [root@localhost /]# vim /etc/samba/smb.conf

This is vim Text Editor:

 First you have set line number

:set number

1 # This is the main Samba configuration file. For detailed information about the

2 # options listed here, refer to the smb.conf(5) manual page. Samba has a hug e

3 # number of configurable options, most of which are not shown in this exampl e.

4#

5 # The Official Samba 3.2.x HOWTO and Reference Guide contains step-by-step
6 # guides for installing, configuring, and using Samba:

7 # http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf

8#

9 # The Samba-3 by Example guide has working examples for smb.conf. This guide
is

10 # generated daily: http://www.samba.org/samba/docs/Samba-Guide.pdf

11 #

12 # In this file, lines starting with a semicolon (;) or a hash (#) are

13 # comments and are ignored. This file uses hashes to denote commentary and

14 # semicolons for parts of the file you may wish to configure.

Etc………………………………………………………………..

 If Go to 314th line and copy 314th line to 320th line

How to copy 7 lines ?

Set cursor on 314th line and select “7YY”

Go to ‘INSERT MODE’ , Paste and Edit:

How to paste copying line?

Set cursor on last line and give paste cmd:p and remove semi colon(;), add path ,
Browseable, allow host and valid user

322 [public]

323 comment = Public Stuff


324 path = /home/samba

325 public = yes

326 writable = yes

327 printable = no

328 write list = +staff

Go to insert mode and add path ,Browseable ,allow host and valid user:

322 [public]

323 comment = Public Stuff

324 path = /Samba_dir

325 public = yes

326 writable = yes

327 printable = no

328 write list = +staff

329 Browseable=Yes

330 allow host =10.0.0.0/24

331 valid user=root

Esc :wq

Step 7:Add Label value for Samba link Directory

How add Label Value for Samba link Directory?

First you check label value for Samba link directory?


How to check label value ?

Syntax: [root@localhost /]#< ll> space <-lZ>

Cmd: [root@localhost /]# ll -lZ

drwxrwxrwx. root root unconfined_u:object_r:default_t:s0 Samba_dir

 This line indicates for don’t set label value

How to set label value for Samba link Directory?

Syntax : [root@localhost /]# <chcon> space <-t> space <samba_share_t> space


</Samba link directory name>

Cmd : [root@localhost /]# chcon -t samba_share_t /Samba_dir

To check cmd:

Cmd :[root@localhost /]# ll –lZ

drwxrwxrwx. root root unconfined_u:object_r:samba_share_t:s0 Samba_dir

Step 8: Set user name and Password for Samba Account( its used for client access
the Server Host to give Username and Password:

How to Set user name and Password for Samba Account?

Synatax: [root@localhost /]# <smbpasswd> space <-a> space <user name>

Cmd: [root@localhost /]# smbpasswd -a root

New SMB password: Enter the new password

Retype new SMB password: Renter the Password

Added user root.

[root@localhost /]#
Step 9:Service :enable Samba service (smb,nmb) on Server machine

How to enable Samba service on Server Machine?

Syntax : [root@localhost /]# <systemctl> space <enable>space <service name>

Cmd: [root@localhost /]# systemctl enable smb

Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to


/usr/lib/systemd/system/smb.service.

Cmd :[root@localhost /]# systemctl enable nmb

Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service


to /usr/lib/systemd/system/nmb.service.

[root@localhost /]#

----------------------------------------------------------------------------------------------

Step 10 : Firewall :add Samba Service on Firewall

 Samba service name :samba

How add Samba Service on Firewall?

Syntax : [root@localhost /]# <firewall-cmd> space <--add-service=service name>


space <--permanent>

Cmd : [root@localhost /]# firewall-cmd --add-service=samba --permanent

success

 You have add service after reload for firewall

How to reload the Firewall?


Syntax: [root@localhost /]# <firewall-cmd> space <--reload>

Cmd : [root@localhost /]# firewall-cmd --reload

success

Service add or not check cmd:

Cmd [root@localhost /]# firewall-cmd --zone=public --list-all

public (default, active)

interfaces: eno16777736

sources:

services: dhcpv6-client ftp samba ssh

ports: 2049/tcp 2049/udp

masquerade: no

forward-ports:

icmp-blocks:

rich rules:

Client machine steps: Windows Operating System

1 .Set IP address for client machine


2 Open Run Cmd: \\Server IP address
To take 2nd Machine (Windows Machine)

Step 1 : Set IP address for windows machine:

How to set IP address for windows Machine?

Open run cmd : Win+R

Type : ncpa.cpl

Step 2: Open Run Cmd: \\Server IP address and click -> Ok

Enter Samba Account user name and password:


Select 1st file: Honey

Create any directory or file:

 If you have any changes on this location automatically reflected on Samba link
directory(ie ,samba_dir).
 You have share any files on samba directory (samba_dir),you can access and
edit the client side.

You might also like