13.06.2023

Setup Samba on CentOS

Intro

Samba is an open source software designed to streamline file and printer sharing across multi-platform networks. It operates on the SMB protocol, which is responsible for managing file and printer sharing in Windows systems. Samba allows users to create shares on their computers that can be accessed by other devices on the network, simplifying the process of file sharing. Its key features include data encryption, user authentication, and remote resource access. Since its inception in 1991, Samba has become a popular alternative to proprietary solutions for file sharing and printing in Windows networks. It is currently one of the most widely used software applications for network file and printer sharing, and can even act as a domain controller to manage user accounts and groups on the network. Additionally, Samba offers the option of creating a web server for file sharing over the Internet.

Install Samba

Initial, deploy programs by inserting:

sudo yum install samba samba-client samba-common

Screenshot №1. Install samba packages

Making shared catalogs

Making catalogs for file sharing is the next process.
Do it:

sudo mkdir /home/username/share1

Operating system support creation multiple directories for different users or groups.

Screenshot №2. Creating new shared folder

Configuration

Afterward, it is necessary to modify config file /etc/samba/smb.conf. Perfom:

sudo nano /etc/samba/smb.conf

That file contains many lines of code.
For application to start correctly, let s edit some of them.

Screenshot №3. Default settings of smb.conf

Access settings

Access settings must be configured by adding the lines:

[share1]
path = /home/username/share1
valid users = username
read only = no

Screenshot №4. Edit smb.conf

Creating Users

To create Samba users,  perform:
Create user in OS:

adduser username

Then set password in smb:

sudo smbpasswd -a username

Screenshot №5. Add new user to smb.conf

Restart Samba

Finally, we restart the Samba service to apply the settings by typing:

sudo systemctl restart smb

You can now try to connect to shared folders from another computer on the network using the username and password you created earlier.

Screenshot №6. Restart smb service

Conclusion

Samba is an excellent tool for sharing files and printers between computers on a local network. This article provides a comprehensive guide for setting up a Samba server on CentOS.

You may be also interested in