Samba server is an open source package very helpful to connect and access windows based files and printer shares. Samba implementation of the
Server Message Block (SMB) protocol.
This post describe to install samba server in linux system,
Download and Install RPM Package:
Download the epel package and install.
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# rpm -Uvh epel-release-7-5.noarch.rpm
# rpm -Uvh epel-release-7-5.noarch.rpm
Install Samba:
Now, install samba package enter the following command,
# yum -y install samba samba-client samba-common
Location and Version:
To find out package installed location and version,
# whereis samba
samba: /usr/lib64/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz
# smbd --version
Version 4.1.1
Configure:
Once the package has been installed in your system configure Samba, edit the file /etc/smb.conf.
Assume that,
Directory : /samba/winshare
Workgroup : WORKGROUP
Share Name: windows
Create a directory /samba/winshare and a sample file,
# mkdir -p /samba/winshare
# chmod -R 0755 /samba/winshare
# chown -R nobody:nobody /samba/winshare
# touch windows_share.txt
# chmod -R 0755 /samba/winshare
# chown -R nobody:nobody /samba/winshare
# touch windows_share.txt
Before editing that smb.conf file take a backup,
# cp /etc/samba/smb.conf /etc/samba/smb.conf_bak
# vim /etc/samba/smb.conf
# vim /etc/samba/smb.conf
workgroup = WORKGROUP
server string = Samba Server Version %v
netbios name = MYSERVER
### Configure samba for accessing Windows System ###
[windows]
comment = Files share to Windows
path = /samba/winshare
browsable =yes
writable = yes
guest ok = yes
read only = no
create mask = 0755
Once the configuration is completed Save and check with testparm command, testparm command is helpful to check an smb.conf file for internal correctness
# testparm
Restart your samba server,
# systemctl enable nmb.service
# systemctl enable smb.service
# systemctl restart nmb.service
# systemctl restart smb.service
# systemctl enable smb.service
# systemctl restart nmb.service
# systemctl restart smb.service
Samba User:
Create a user and set password,
# useradd linuxfaq
# smbpasswd -a linuxfaq
# smbpasswd -a linuxfaq
New SMB password:
Retype new SMB password:
Added user linuxfaq.
Give Permission:
we need to allow the selinux for the samba configuration as follows:
# chcon -t samba_share_t /samba/winshare
Restart your samba server again,
Connect Windows System
Now, you can access Samba sharing files to your windows system. Open RUN command prompt Windows key + R type the following command, For example your Linux system IP address is 192.168.1.100
\\192.168.1.100\windows
Secured samba server
Can set proper permission for specific users and groups access files or directories, The group name centos and user fedoragroup name : centos
user name : fedora
# groupadd centos
# useradd fedora
# useradd fedora
Assign a user fedora to centos group
# mkdir /ubuntu -p
# chown -R ubuntu:centos /ubuntu/
# chmod -R 0770 /ubuntu/
# chown -R ubuntu:centos /ubuntu/
# chmod -R 0770 /ubuntu/
In smb.conf
[centosusers]
comment = Files shares for centosuses
path = /ubuntu
valid users = @centos
browsable =yes
writable = yes
guest ok = yes
read only = no
create mask = 0755
hosts allow = 192.168.1.100
Finally restart your Samba server,
# systemctl restart nmb.service
# systemctl restart smb.service
# systemctl restart smb.service
Also can check on your terminal in Linux system,
# smbclient //192.168.1.100/centosusers -U ubuntu
Enter samba's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \> ls
Comments (0)