How to Install Samba Server on CentOS 8

# Install Samba Server
dnf install samba samba-common samba-client -y

# verify the Samba Service
systemctl status smb

#Create a Public Share Directory
#First, create a shared folder named public and also create two files inside the #public directory:

mkdir -p /samba/share/public
 touch /samba/share/public/file1.txt
 touch /samba/share/public/file2.txt

# assign the necessary permissions and ownership with the following command:

chmod -R 0755 /samba/share/
 chmod -R 0755 /samba/share/public
 chown -R nobody:nobody /samba/share
 chown -R nobody:nobody /samba/share/publ

nano /etc/samba/smb.conf

workgroup = WORKGROUP
server string = Samba Server %v
netbios name = samba-server
security = user
map to guest = bad user
dns proxy = no

path = /samba/share/public
browsable =yes
writable = yes
guest ok = yes
read only = no

# restart
systemctl restart smb


# Configure SELinux and Firewall
# Next, set the proper SELinux boolean and security context values on share # directory with the following command:

setsebool -P samba_export_all_ro=1 samba_export_all_rw=1
semanage fcontext -a -t samba_share_t "/samba/share/public(/.*)?"
restorecon /samba/share/public
# Next, all Samba service through firewalld with the following command:

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

Leave a Reply

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