We’ll look at how to set up Samba File Share on AlmaLinux 9 | Oracle Linux 9 in this guide. Samba is a free and open-source software that enables sharing files across a network simple for Windows and Linux/Unix systems. Samba is essentially an open-source reimplementation of the SMB and CIFS networking protocols. Samba provides file sharing, printing, and domain control services within the network in addition to file sharing between clients and hosts.
Benefits of using Samba File Sharing
The following are the advantages of using Samba:
- It enables Linux/Unix servers and Windows-based clients to communicate with one another.
- File systems are shared.
- Printers installed on both the server and the clients can be shared.
- Clients logging into a Windows domain must be authenticated.
- Samba is a free and open source application.
Configure Samba File Share on AlmaLinux 9 | Oracle Linux 9
The steps below will guide you on how to Configure Samba File Share on AlmaLinux 9 | Oracle Linux 9.
Step 1: Install Samba Packages on AlmaLinux 9 | Oracle Linux 9
Update your AlmaLinux 9 | Oracle Linux 9 System as follows:
sudo dnf update -y
Run the following command to install Samba:
$ sudo dnf install samba samba-client -y
Last metadata expiration check: 15:33:26 ago on Mon 27 Jan 2025 07:05:08 AM EAT.
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
samba x86_64 4.19.4-6.el8_10 baseos 1.0 M
samba-client x86_64 4.19.4-6.el8_10 baseos 741 k
Installing dependencies:
avahi-libs x86_64 0.7-27.el8_10.1 baseos 61 k
cups-libs x86_64 1:2.2.6-62.el8_10 baseos 436 k
libicu x86_64 60.3-2.el8_1 baseos 8.8 M
libnetapi x86_64 4.19.4-6.el8_10 baseos 216 k
libsmbclient x86_64 4.19.4-6.el8_10 baseos 155 k
libwbclient x86_64 4.19.4-6.el8_10 baseos 128 k
samba-client-libs x86_64 4.19.4-6.el8_10 baseos 5.0 M
samba-common noarch 4.19.4-6.el8_10 baseos 233 k
samba-common-libs x86_64 4.19.4-6.el8_10 baseos 182 k
samba-common-tools x86_64 4.19.4-6.el8_10 baseos 541 k
samba-dcerpc x86_64 4.19.4-6.el8_10 baseos 755 k
samba-ldb-ldap-modules x86_64 4.19.4-6.el8_10 baseos 112 k
samba-libs x86_64 4.19.4-6.el8_10 baseos 202 k
Transaction Summary
=====================================================================================================================================================
Install 15 Packages
Total download size: 18 M
Installed size: 63 M
Is this ok [y/N]: y
Step 2: Configure Samba Share on AlmaLinux 9 | Oracle Linux 9
We’ll do some adjustments now that Samba is installed to improve the application’s performance.
Before altering the configuration file, make a backup to allow for a rollback if the file becomes corrupted:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bk
Create samba user as follows:
sudo adduser -M sambauser
With the following command, create a Samba password for the newly created user:
$ sudo smbpasswd -a sambauser
New SMB password:<ENTER PASSWORD>
Retype new SMB password:<RE-ENTER PASSWORD>
Added user sambauser.
Now, in the /srv directory path, create a samba share called myfiles.
sudo mkdir -p /srv/myfiles
echo "Test File 1" > /srv/myfiles/test1.txt
echo "Test File 2" > /srv/myfiles/test2.txt
Following that, we’ll assign permissions and ownerships as seen below:
sudo chmod -R 755 /srv/myfiles
sudo chown -R nobody:nobody /srv/myfiles
sudo chcon -t samba_share_t /srv/myfiles
Using the command below, create a new Samba configuration file.
sudo vim /etc/samba/smb.conf
Add the following to the file created above:
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = SambaServer
security = user
map to guest = bad user
dns proxy = no
[Public]
path = /srv/myfiles
browsable =yes
writable = yes
guest ok = yes
read only = no
Save and exit the file.
Run the following command to check the configuration:
$ sudo testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Weak crypto is allowed
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters
[global]
dns proxy = No
map to guest = Bad User
netbios name = ALMALINUX 9
security = USER
server string = Samba Server %v
idmap config * : backend = tdb
[Public]
guest ok = Yes
path = /srv/myfiles
read only = No
Step 3: Samba Share Service Management on AlmaLinux 9 | Oracle Linux 9
Run the following commands to 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 service if it’s active and running:
$ sudo systemctl status smb
● smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2025-01-27 22:46:49 EAT; 10s ago
Docs: man:smbd(8)
man:samba(7)
man:smb.conf(5)
Main PID: 47024 (smbd)
Status: "smbd: ready to serve connections..."
Tasks: 3 (limit: 36110)
Memory: 9.8M
CGroup: /system.slice/smb.service
├─47024 /usr/sbin/smbd --foreground --no-process-group
├─47026 /usr/sbin/smbd --foreground --no-process-group
└─47027 /usr/sbin/smbd --foreground --no-process-group
Jan 27 22:46:48 AlmaLinux systemd[1]: Starting Samba SMB Daemon...
Jan 27 22:46:48 AlmaLinux smbd[47024]: [2025/01/27 22:46:48.995674, 0] ../../source3/smbd/server.c:1748(main)
Jan 27 22:46:48 AlmaLinux smbd[47024]: smbd version 4.19.4 started.
Jan 27 22:46:48 AlmaLinux smbd[47024]: Copyright Andrew Tridgell and the Samba Team 1992-2023
Jan 27 22:46:49 AlmaLinux systemd[1]: Started Samba SMB Daemon.
Verify status of both nmb service if it’s active and running:
$ sudo systemctl status nmb
● nmb.service - Samba NMB Daemon
Loaded: loaded (/usr/lib/systemd/system/nmb.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2025-01-27 22:46:49 EAT; 2min 40s ago
Docs: man:nmbd(8)
man:samba(7)
man:smb.conf(5)
Main PID: 47164 (nmbd)
Status: "nmbd: ready to serve connections..."
Tasks: 1 (limit: 36110)
Memory: 3.0M
CGroup: /system.slice/nmb.service
└─47164 /usr/sbin/nmbd --foreground --no-process-group
Jan 27 22:46:49 AlmaLinux systemd[1]: Starting Samba NMB Daemon...
Jan 27 22:46:49 AlmaLinux nmbd[47164]: [2025/01/27 22:46:49.307499, 0] ../../source3/nmbd/nmbd.c:903(main)
Jan 27 22:46:49 AlmaLinux nmbd[47164]: nmbd version 4.19.4 started.
Jan 27 22:46:49 AlmaLinux nmbd[47164]: Copyright Andrew Tridgell and the Samba Team 1992-2023
Jan 27 22:46:49 AlmaLinux systemd[1]: Started Samba NMB Daemon.
Step 4: Configure Firewall for Samba Share
Now we’ll allow samba services to pass over the firewall, allowing access from the outside.
sudo firewall-cmd --add-service=samba --zone=public --permanent
sudo firewall-cmd --reload
Step 5: Accessing Samba share from Windows Client
Press Windows Key + R and type the server hostname or IP address to access shared folders on Windows Client.
When you press enter, a shared folder named Public will appear, as illustrated below:
The following are the files contained in the Samba sharing server’s Public directory which is mapped to /srv/myfiles
:
Step 6: Configure Samba client on Linux
To access the Samba share directory from another system, we’ll need to install the Samba client. On Debian Linux, I’m going to install the Samba client.
sudo apt install samba-client cifs-utils
To acquire temporary access to a Samba share, run the command with the syntax listed below:
$ smbclient //sambaserver-ip/share-dir -U sambauser
##For our case:
$ smbclient //192.168.1.253/Public -U sambauser
Here is the output:
For persistent access, mount the Samba share to a directory:
sudo mkdir -p /mounts/shares
sudo mount -t cifs -o username=sambauser //192.168.1.253/Public /mounts/shares
Conclusion
Samba has been successfully installed on AlmaLinux 9 | Oracle Linux 9, and the shared directory has been mounted on Windows and Debian clients.
Explore CloudSpinx for file server hosting services.
Similar Guides: