Samba is an open-source software suite that allows file and print sharing between different operating systems.
To start, update your CentOS 8 system to ensure you have the latest packages:
$ sudo dnf update -y
Use the following command to install Samba:
$ sudo dnf install samba samba-client -y
Next, you need to configure the Samba service by editing the main configuration file:
$ sudo vi /etc/samba/smb.conf
Make the necessary changes according to your requirements. Here's an example of a basic configuration:
# Global section
[global]
workgroup = WORKGROUP
server string = Samba Server
log file = /var/log/samba/%m.log
max log size = 50
security = user
encrypt passwords = yes
# Share definition
[share]
path = /path/to/share
browseable = yes
writable = yes
guest ok = no
valid users = user1 user2
Create a user who will have access to the Samba share:
$ sudo useradd -M -s /sbin/nologin samba_user
Set a password for the user:
$ sudo smbpasswd -a samba_user
Enable the Samba service to start automatically on system boot:
$ sudo systemctl enable smb
Start the Samba service:
$ sudo systemctl start smb
If you're using Firewalld, allow Samba services in the firewall:
$ sudo firewall-cmd --permanent --add-service=samba
$ sudo firewall-cmd --reload
You can now access the Samba share from any Windows, Linux, or macOS machine using the following path:
\\\
Replace with the IP address or hostname of your CentOS system, and with the name of the share defined in the smb.conf file.
That's it! You have successfully installed and configured Samba on CentOS 8.
What our customers say about us
Create your free account today.