Samba in an open source Linux application that is used for sharing data not only between Linux systems but also with Windows systems. Samba server is installed on central Linux server where information is stored in variety of media and accessed using windows client or Linux using Samba client.

Sharing of data has become a critical part of knowledge management within organizations. An organization or an individual creates data and stores it either on a server or desktop for accessibility. There has been a barrier to sharing data between Linux and Windows directly. Some even tend to use removable media in sharing data, which calls upon physical access to the host server. In this article, we will be discussing how to install and configure samba file sharing on Rocky Linux 8

Rocky Linux 8 will be our central server with Samba server configured and we wi’ll be able to access files from Windows systems and Linux systems.

Step 1: Install Samba Packages on Rocky Linux 8

Login to your Rocky Linux server, open terminal then run the command bellow to update the Linux system.

sudo yum update

Install Samba by executing this command in terminal.

sudo yum install samba samba-common samba-client

Screen below will appear prompting you to accept the installation processes by typing Y the click ENTER.

When installation completes successfully you will see the screen below.

Step 2: Configure Samba Share on Rocky Linux 8

Now that we have Samba installed, we are going to do some configurations to enhance performance of the application. It is important that you first backup the configuration file before editing to create a room for roll back should you have the file corrupted.

Run command shown to create a backup file.

sudo mv /etc/samba/smb.comf /etc/samba/smb.conf.bk

Create a directory to be shared then give it necessary permissions and ownership.

sudo mkdir -p /srv/samba/repository
sudo chmod -R 755 /srv/samba/repository
sudo chown -R nobody:nobody /srv/samba/repository
sudo chcon -t samba_share_t /srv/samba/repository

Create a new configuration file for Samba using the command below.

sudo vim /etc/samba/smb.conf

Edit the file by adding the lines shown here.

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

path = /srv/samba/repository
browsable =yes
writable = yes
guest ok = yes
read only = no

Save and close the editor by pressing Esc, Ctrl+; wq! Then ENTER.

Use command below to verify the configurations.

sudo testparm

Step 3: Firewall Settings

In this step, we are going to allow samba services through the firewall to enable accessibility from outside.

sudo firewall-cmd --add-service=samba --zone=public --parmanent
sudo firewall-cmd --reload

Step 4: Starting, enabling and managing Samba services

Start and and enable samba and nmb services.

sudo systemctl start smb
sudo systemctl enable smb
sudo systemctl start nmb
sudo systemctl enable nmb

Verify status of both smb and nmb that are active and running.

sudo systemctl status smb
sudo systemctl status nmb

Step 5: Access Samba share with Windows Client

Launch run dialogue in windows by pressing Windows Key + R.

Enter hostname or IP-Address of the server then press Enter Key.


You can add a file or directory either from samba server or windows client machine to the repository.

Step 6: Secure Share Configuration on Rocky Linux 8

Samba allows public access without verification and also private share where one has to be authenticated to access shared resources. We are going to configure a private directory to shared with samba and accessed using username and password.

Add Samba user group in Rocky Linux 8

sudo groupadd private_group

Add new user to samba group you just created.

sudo useradd -g private_group techview 

Create a secure folder then grant it relative permissions and ownership .

sudo mkdir -R -p /srv/samba/private
sudo chmod -R 770 /srv/samba/private
sudo chcon -t samba_share_t /srv/samba/private
sudo chown -R root:private_group /srv/samba/private

Create password for Samba user we just created that will be used for authentication when accessing the directory.

sudo smbpasswd -a techview

Edit samba configuration file to add secure share configurations. Add lines below the command and edit to match your configurations.

$ sudo vim /etc/samba/smb.conf
path = /srv/samba/private
valid users = @private
guest ok = no
writable = yes
browsable = yes

Save and exit. Restart or reload samba services to apply configurations.

sudo systemctl restart smb
sudo systemctl restart nmb

Accessing Samba Secure files using Windows Systems.

Press Windows Key + R, enter the server hostname or IP address to access the shared folders.

When you open a private folder will prompt for username and password to grant access right to the files.

Below is a folder and file I created in private directory on Samba share server.

Access Samba Secure Directory with Linux.

Install samba client to use smbclient command. Use command below to access secure folder in Rocky Linux 8 with Samba Server.

smbclient //server-IP/private -U techview

Enter Samba user password when prompted to.

This is all that you need to have Samba running in your Rocky Linux to enable public and private sharing of data over internet. Hope the guide was helpful.