How To Install Samba on AlmaLinux 8

Install Samba on AlmaLinux 8

In this tutorial, we will show you how to install Samba on AlmaLinux 8. For those of you who didn’t know, 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. Samba enables Linux/Unix machines to communicate with Windows machines in a network.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of Samba file sharing on an AlmaLinux 8. You can follow the same instructions for CentOS and Rocky Linux.

Prerequisites

  • A server running one of the following operating systems: AlmaLinux 8, CentOS, and Rocky Linux 8.
  • It’s recommended that you use a fresh OS install to prevent any potential issues
  • A non-root sudo useror access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Samba on AlmaLinux 8

Step 1. First, let’s start by ensuring your system is up-to-date.

sudo dnf update
sudo dnf install epel-release mod_ssl

Step 2. Installing Samba on AlmaLinux 8.

By default, Samba is available on the AlmaLinux 8 base repository. Now we run the following command to install Samba to your system:

sudo dnf install samba samba-common samba-client

Confirm the installed software package with this command:

rpm -qi samba

Once the installation is complete, now enable Samba (to start automatically upon system boot), start the Samba, and verify the status using the commands below:

sudo systemctl start smb
sudo systemctl enable smb
sudo systemctl status smb

Step 3. Configuring Samba.

Now we edit the configuration file of samba and make some changes and entries in it:

sudo mkdir -p /home/idroot

Next, we will assign permissions and ownerships as follows:

sudo chmod -R 755 /home/idroot
sudo chown -R nobody:nobody /home/idroot
sudo chcon -t samba_share_t /home/idroot

Let’s edit the Samba configuration file:

sudo nano /etc/samba/smb.conf

Add the following files:

[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = idroot SmbSvr
security = user
map to guest = bad user
dns proxy = no

[Public]
path = /home/idroot
browsable =yes
writable = yes
guest ok = yes
read only = no

Save your changes to the file and exit it. Then, restart the Samba service for the new changes to take effect:

sudo systemctl restart smb

Verify the configuration using this command:

sudo testparm

Step 4. Configure Firewall.

AlmaLinux comes with firewalld enabled by default, and it will block other connections from other computers that are trying to access our Samba service. We must open the appropriate ports so that the samba-shared resources can be accessed from other machines:

sudo firewall-cmd --permanent --add-service=samba
sudo firewall-cmd --reload

Step 5. Secure Samba File Sharing.

You could require your Samba users to password authenticate their access to shared files. Let’s create a Samba user group on our server:

sudo groupadd sambagrp
sudo useradd -g sambagrp sambausr

Next, create a secure folder then grant it relative permissions and ownership:

sudo mkdir -p /home/idrootprivateshare
sudo chmod -R 770 /home/idrootprivateshare
sudo chcon -t samba_share_t /home/idrootprivateshare
sudo chown -R root:sambagrp /home/idrootprivateshare

Next, create a password for the Samba user we just created that will be used for authentication when accessing the directory:

sudo smbpasswd -a sambausr

Then, edit the Samba configuration file to add secure share configurations:

sudo nano /etc/samba/smb.conf

Add the following files:

[Private]
    path = /home/idrootprivateshare
    valid users = @private
    guest ok = no
    writable = yes
    browsable = yes

Finally, restart the Samba daemons to apply configurations:

sudo systemctl restart smb

Step 6. Accessing Samba server from Client.

On a Linux client, install the software using this command:

sudo dnf install samba-client

To access the share, this is the format:

smbclient //server-IP-address/Public

To access samba share from windows press Windows Key+ R to launch Run Dialogue. Enter the IP address or Hostname and press Enter.

Congratulations! You have successfully installed Samba. Thanks for using this tutorial for installing Samba file sharing on your AlmaLinux 8 system. For additional help or useful information, we recommend you check the official Samba website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!