Thursday, December 31, 2020

How to install and configure Samba share with windows and Linux (CentOs ,Redhat,Ubantu)

 #Install and Configure Samba :

Find the package install or not

[root@-86 ~]# rpm -qa samba 

[root@-86 ~]# yum install samba samba-client samba-common

#Create Directory 

[root@-86 ~]#mkdir  /sharedata/

[root@-86 ~]#chmod /sharedata/

[root@-86 ~]#chcon -R  -t  samba_share_t  /sharedata/        (Set selinux )
[root@-86 ~]#setsebool -P samba_enable_home_dirs  on 
 

#Create user and set smb user password 

[root@-86 ~]#useradd  vmbackup

[root@-86 ~]#chcon -R -t samba_share_t /sharedata/
[root@-86 ~]#setsebool -P samba_enable_home_dirs on


[root@-86 ~]#smbpasswd -a vmbackup
[root@-86 ~]#groupadd smbgroup
[root@-86 ~]#usermod -G smbgroup vmbackup

#Configure smb.cnf  file

[root@-86 ~]#vim /etc/samba/smb.conf        (Go to last line past this line)

[WEB_BK]
comment=Shared Directory
browseable=yes
path=/sharedata
public=yes
writeable=yes
valid users=vmbackup
create mask=0770

#Set firewall 

[root@-86 ~]# firewall-cmd --add-service=samba --permanent
[root@-86 ~]#firewall-cmd --reload
 

#Restart samba sevices

[root@-86 ~]# systemctl restart smb
[root@-86 ~]# systemctl restart nmb
 

#Lets check  and Samba & Mount dir at client machine

[root@dev ~]# smbclient -L 192.168.105.86 -U vmbackup
Enter SAMBA\vmbackup's password:

    Sharename       Type      Comment
    ---------       ----      -------
    print$                  Disk      Printer Drivers
    sharedata           Disk      Shared Directory
    IPC$                    IPC       IPC Service (Samba 4.9.1)
    vmbackup           Disk      Home Directories
   Reconnecting with SMB1 for workgroup listing.

    Server               Comment
    ---------            -------

    Workgroup            Master
    ---------                      -------
    MYGROUP              48
    SAMBA                   VMS-86
    WORKGROUP        SERVER253
 

#Mount share directory 

[root@dev ~]# mount -t cifs -o username=vmbackup,password=redhat@123 //192.168.103.86/sharedata    dd/
[root@dev ~]# df -h
Filesystem                       Size  Used Avail Use% Mounted on
devtmpfs                         1.9G     0  1.9G   0% /dev
/dev/mapper/centos-home           19G   33M   19G   1% /home
/dev/sdb1                        2.0G  6.0M  1.8G   1% /root/linux
/dev/mapper/vg_web_group-web_lv  477M  2.3M  445M   1% /root/devops
//192.168.103.86/sharedata       5.0T   33M  5.0T   1% /root/dd

No comments:

Post a Comment

How to Find the Third highest salary in mysql

  set @b:=0; set @b1:=3;   # #select distinct salary,@b:=@b+1 as Row_no from emp select  * from emp where salary=( select salary from ( sele...