Sharing files is an essential part of server administration. It allows sharing of resources across the network which are needed by users to carry out their tasks. One of the widely used file-sharing software is Samba.
General Configuration (/etc/smb.conf)
Samba, a re-implementation of the popular SMB (server message block) protocol, is a stable and free application that allows sharing of files and print services across a network. The software is installed on a central Linux server from which shared files can be accessed from both Linux and Windows systems.
In this guide, we will walk you through the installation of the Samba Server on RHEL-based distributions such as CentOS Stream, Rocky Linux, and Alma Linux.
Step 1: Install Samba in Linux
To get started out with Samba, install the Samba core packages including the client package:
The command installs the packages specified along with the dependencies as displayed on the output. After the installation is complete, you will get a summary of all the packages that have been installed.
Step 2: Create and Configure Samba Shares
Once all the samba packages have been installed, the next step is to configure the samba shares. A samba share is simply a directory that is going to be shared across client systems in the network.
Here, we are going to create a samba share called /data in the /srv/tecmint/ directory path.
Step 3: Accessing Samba Share from Windows
The following window labeled ‘’ will pop up. Remember, this is the directory that points to our samba share in the directory.
Perfect. We have successfully managed to access our s. However, our directory is accessible to anyone and everybody can edit and delete files at will, which is not recommended especially if you plan to host sensitive files.
Step 4: Secure Samba Share Directory
Step 5: Accessing Samba Share from Linux Client
Install and Configure Samba
1. Installing Samba
To install Samba, we run:
sudo apt update sudo apt install samba
We can check if the installation was successful by running:
2. Setting up Samba
Now that Samba is installed, we need to create a directory for it to share:
The command above creates a new folder
sambashare in our home directory which we will share later.
The configuration file for Samba is located at
/etc/samba/smb.conf. To add the new directory as a share, we edit the file by running:
sudo nano /etc/samba/smb.conf
At the bottom of the file, add the following lines:
[sambashare] comment = Samba on Ubuntu path = /home/username/sambashare read only = no browsable = yes
Ctrl-O to save and
Ctrl-X to exit from the nano text editor.
What we’ve just added
- comment: A brief description of the share.
path: The directory of our share.
read only: Permission to modify the contents of the share folder is only granted when the value of this directive is
browsable: When set to
yes, file managers such as Ubuntu’s default file manager will list this share under “Network” (it could also appear as browseable).
Now that we have our new share configured, save it and restart Samba for it to take effect:
sudo service smbd restart
Update the firewall rules to allow Samba traffic:
sudo ufw allow samba