
File servers often have to accommodate different types of client systems. Windows systems can connect to and access files as well as other Linux and macOS systems with the help of Samba. In this article, we are going to teach you How to Install and Uninstall Samba on AlmaLinux 8. It is interesting to note that installing Samba is a great way to prepare your file server on AlmaLinux.
What is Samba?
Samba is free software, protocol, and networking tool that provides Windows collaboration with Linux and Unix that allows Windows to share files and printers on a Unix host. Samba also allows Unix users to access shared resources on Windows systems. It is interesting to know that Samba was created by Andrew Trigell and is useful for people who have both Windows and Unix systems in their network. Samba implements the SMB network protocol again. It should be noted that Samba uses the SMB protocol to share files between different operating systems on Unix-based operating systems such as Linux and Mac.
How to Install Samba on AlmaLinux 8
Before starting the process of installing Samba, we recommend that you choose and purchase a plan from the Linux VPS server provided in NeuronVM.
In the first step, you should install Samba on AlmaLinux 8 by executing the following command:
sudo dnf install samba samba-client
SMB is a daemon that handles the actual transfer and sharing operations and nmb performs the NetBIOS name resolutions and allows resources to appear in Windows while browsing the network. After installing the packages, you need to start and enable the SMB and the NMB daemons at the boot:
sudo systemctl enable --now {smb,nmb}
AlmaLinux has a firewalld that is enabled by default. The firewall blocks other connections of computers trying to access the Samba service. In this step, you need to allow the proper ports through the firewalld with the help of the following command:
sudo firewall-cmd --permanent --add-service=samba sudo firewall-cmd --reload
If configuration needs, you can add the –zone option to the above command.
How to Create a Samba User on AlmaLinux 8
You can setup a Samba Share without the need for an account, But it’s better for people who connect to Samba Share to create user accounts. Each Samba user needs a normal user account on the AlmaLinux account. You can create a new Samba account by running the following command:
sudo adduser -M sambauser -s /sbin/nologin
The -M option is the short form for –no-create-home, and the -s option allows you to specify a shell: /sbin/nologin. There is no need to set a password for a user account, just a password for the Samba service. You can create a Samba password for the newly created user by entering the following command:
sudo smbpasswd -a sambauser
How to Configure Samba to Share a Directory on AlmaLinux 8
Now it’s time to configure the directory you want to share via Samba:
In this tutorial, a shared directory is made at /mnt/shared.
sudo mkdir -p /mnt/shared sudo chmod 777 /mnt/shared
Then you need to open your configuration file with your favorite text editor to edit it:
sudo nano /etc/samba/smb.conf
Next, you should go all the way to the bottom of the file and paste the following lines:
[neuronvm] path = /mnt/shared guest ok = no read only = no
Save the changes to the file and exit it. You should restart the Samba service by entering the following command for the changes to take effect:
sudo systemctl restart {smb,nmb}
Now it’s time to allow Samba through SELinux. SELinux is also enabled by default in AlmaLinux. You should assign the appropriate context to your shared directory and files. This allows Samba to function while keeping SELinux in the recommended enforcing mode:
sudo chcon -R -t samba_share_t /mnt/shared
Connecting to Samba Server from AlmaLinux
Other systems should be able to connect to this directory to upload or download files from the Samba server. First, you need to create an empty directory by entering the following command to use it as a mount point for the remote Samba share:
sudo mkdir -p /mnt/fileserver
In this step, you need to install the remote Samba share to the folder you just created by executing the following command:
sudo mount -t cifs -o username-sambauser //192.168.1.10/neuronvm/mnt/fileserver
Enter the password to mount Samba Share.
Now you should access your Samba share from Gnome’s file manager:
smb://127.0.0.1/neuronvm/
Remember to replace the IP address.
The Samba share will be installed on the left side of the Gnome file manager.
How to Uninstall Samba on AlmaLinux 8
You can remove Samba from your AlmaLinux server by executing the following command:
sudo apt-get remove --purge samba
If you have client problems, enter the following command to remove the SMB client:
sudo apt-get remove --purge smbclient libsmbclient
Conclusion
This article taught you how to install and uninstall Samba on AlmaLinux 8. Using this article should allow you to create a file server that can host connections from different operating systems. I hope this tutorial was useful for you.
FAQ
You can find the samba configuration file at /etc/samba/smb. conf.
If we compare these two, FTP is much faster and more efficient than samba. file transferring protocol in FTP is better.