How to create Permission- based configuration in Samba on Oracle Linux 9.3
To Create Permission-Based Configuration In Samba On Oracle Linux 9.3
Introduction
Samba is an open-source software. A Samba file server enables file sharing across different operating systems over a network. The Samba server configuration manages Samba shares, users, and basic server settings.
Procedure Steps
Step 1: Check the OS version by using the below command.
[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3
Step 2: Install Samba by using the below command.
[root@linuxhelp ~]# yum install samba* -y
Oracle Linux 9 BaseOS Latest (x86_64) 28 kB/s | 3.6 kB 00:00
Oracle Linux 9 Application Stream Packages (x86_64) 36 kB/s | 3.9 kB 00:00
Oracle Linux 9 UEK Release 7 (x86_64) 30 kB/s | 3.0 kB 00:00
Package samba-client-libs-4.18.6-101.el9_3.x86_64 is already installed.
Package samba-common-4.18.6-101.el9_3.noarch is already installed.
Package samba-common-libs-4.18.6-101.el9_3.x86_64 is already installed.
Dependencies resolved.
===========================================================================================================================================================================================================
Package Architecture Version Repository Size
===========================================================================================================================================================================================================
Installing:
samba x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 1.0 M
samba-client x86_64 4.18.6-102.0.1.el9_3 ol9_appstream 706 k
samba-common-tools x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 466 k
samba-dcerpc x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 692 k
samba-krb5-printing x86_64 4.18.6-102.0.1.el9_3 ol9_appstream 20 k
samba-ldb-ldap-modules x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 26 k
samba-libs x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 130 k
samba-tools x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 22 k
samba-usershares x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 12 k
samba-vfs-iouring x86_64 4.18.6-102.0.1.el9_3 ol9_appstream 23 k
samba-winbind x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 435 k
samba-winbind-clients x86_64 4.18.6-102.0.1.el9_3 ol9_appstream 85 k
samba-winbind-krb5-locator x86_64 4.18.6-102.0.1.el9_3 ol9_appstream 26 k
samba-winbind-modules x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 67 k
samba-winexe x86_64 4.18.6-102.0.1.el9_3 ol9_appstream 79 k
Upgrading:
libsmbclient x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 72 k
libwbclient x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 40 k
samba-client-libs x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 5.1 M
samba-common noarch 4.18.6-102.0.1.el9_3 ol9_baseos_latest 158 k
samba-common-libs x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 102 k
Installing dependencies:
libnetapi x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 139 k
python3-dns noarch 2.3.0-2.el9 ol9_baseos_latest 799 k
python3-ldb x86_64 2.7.2-2.el9 ol9_baseos_latest 59 k
python3-samba x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 3.7 M
python3-samba-dc x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 392 k
python3-talloc x86_64 2.4.0-2.el9 ol9_baseos_latest 20 k
python3-tdb x86_64 1.4.8-2.el9 ol9_baseos_latest 26 k
python3-tevent x86_64 0.14.1-2.el9 ol9_baseos_latest 22 k
samba-dc-libs x86_64 4.18.6-102.0.1.el9_3 ol9_baseos_latest 28 k
Transaction Summary
===========================================================================================================================================================================================================
Install 24 Packages
Upgrade 5 Packages
Total download size: 14 M
Downloading Packages:
(1/29): python3-ldb-2.7.2-2.el9.x86_64.rpm 456 kB/s | 59 kB 00:00
(2/29): libnetapi-4.18.6-102.0.1.el9_3.x86_64.rpm 703 kB/s | 139 kB 00:00
(3/29): python3-dns-2.3.0-2.el9.noarch.rpm 3.2 MB/s | 799 kB 00:00
(4/29): python3-talloc-2.4.0-2.el9.x86_64.rpm 619 kB/s | 20 kB 00:00
(5/29): python3-tdb-1.4.8-2.el9.x86_64.rpm 662 kB/s | 26 kB 00:00
(6/29): python3-samba-4.18.6-102.0.1.el9_3.x86_64.rpm 8.5 MB/s | 3.7 MB 00:00
(7/29): python3-tevent-0.14.1-2.el9.x86_64.rpm 76 kB/s | 22 kB 00:00
(8/29): samba-common-tools-4.18.6-102.0.1.el9_3.x86_64.rpm 3.2 MB/s | 466 kB 00:00
(9/29): samba-4.18.6-102.0.1.el9_3.x86_64.rpm 5.6 MB/s | 1.0 MB 00:00
(10/29): python3-samba-dc-4.18.6-102.0.1.el9_3.x86_64.rpm 692 kB/s | 392 kB 00:00
(11/29): samba-dc-libs-4.18.6-102.0.1.el9_3.x86_64.rpm 1.0 MB/s | 28 kB 00:00
(12/29): samba-ldb-ldap-modules-4.18.6-102.0.1.el9_3.x86_64.rpm 633 kB/s | 26 kB 00:00
(13/29): samba-libs-4.18.6-102.0.1.el9_3.x86_64.rpm 2.0 MB/s | 130 kB 00:00
(14/29): samba-dcerpc-4.18.6-102.0.1.el9_3.x86_64.rpm 7.4 MB/s | 692 kB 00:00
(15/29): samba-tools-4.18.6-102.0.1.el9_3.x86_64.rpm 279 kB/s | 22 kB 00:00
(16/29): samba-usershares-4.18.6-102.0.1.el9_3.x86_64.rpm 5.2 kB/s | 12 kB 00:02
(17/29): samba-client-4.18.6-102.0.1.el9_3.x86_64.rpm 7.0 MB/s | 706 kB 00:00
(18/29): samba-winbind-modules-4.18.6-102.0.1.el9_3.x86_64.rpm 23 kB/s | 67 kB 00:02
(19/29): samba-winbind-4.18.6-102.0.1.el9_3.x86_64.rpm 138 kB/s | 435 kB 00:03
(20/29): samba-krb5-printing-4.18.6-102.0.1.el9_3.x86_64.rpm 11 kB/s | 20 kB 00:01
(21/29): samba-vfs-iouring-4.18.6-102.0.1.el9_3.x86_64.rpm 13 kB/s | 23 kB 00:01
(22/29): samba-winbind-clients-4.18.6-102.0.1.el9_3.x86_64.rpm 37 kB/s | 85 kB 00:02
(23/29): libsmbclient-4.18.6-102.0.1.el9_3.x86_64.rpm 3.9 MB/s | 72 kB 00:00
(24/29): libwbclient-4.18.6-102.0.1.el9_3.x86_64.rpm 2.6 MB/s | 40 kB 00:00
(25/29): samba-client-libs-4.18.6-102.0.1.el9_3.x86_64.rpm 11 MB/s | 5.1 MB 00:00
(26/29): samba-common-4.18.6-102.0.1.el9_3.noarch.rpm 6.1 MB/s | 158 kB 00:00
(27/29): samba-common-libs-4.18.6-102.0.1.el9_3.x86_64.rpm 5.2 MB/s | 102 kB 00:00
(28/29): samba-winbind-krb5-locator-4.18.6-102.0.1.el9_3.x86_64.rpm 12 kB/s | 26 kB 00:02
(29/29): samba-winexe-4.18.6-102.0.1.el9_3.x86_64.rpm 37 kB/s | 79 kB 00:02
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.9 MB/s | 14 MB 00:07
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: samba-common-4.18.6-102.0.1.el9_3.noarch 1/34
Upgrading : samba-common-4.18.6-102.0.1.el9_3.noarch 1/34
Running scriptlet: samba-common-4.18.6-102.0.1.el9_3.noarch 1/34
Upgrading : samba-client-libs-4.18.6-102.0.1.el9_3.x86_64 2/34
Running scriptlet: libwbclient-4.18.6-102.0.1.el9_3.x86_64 3/34
Upgrading : libwbclient-4.18.6-102.0.1.el9_3.x86_64 3/34
Upgrading : samba-common-libs-4.18.6-102.0.1.el9_3.x86_64 4/34
Installing : samba-libs-4.18.6-102.0.1.el9_3.x86_64 5/34
Installing : libnetapi-4.18.6-102.0.1.el9_3.x86_64 6/34
Installing : samba-dcerpc-4.18.6-102.0.1.el9_3.x86_64 7/34
Installing : samba-dc-libs-4.18.6-102.0.1.el9_3.x86_64 8/34
Upgrading : libsmbclient-4.18.6-102.0.1.el9_3.x86_64 9/34
Installing : python3-tdb-1.4.8-2.el9.x86_64 10/34
Installing : python3-talloc-2.4.0-2.el9.x86_64 11/34
Installing : python3-ldb-2.7.2-2.el9.x86_64 12/34
Installing : samba-client-4.18.6-102.0.1.el9_3.x86_64 13/34
Running scriptlet: samba-client-4.18.6-102.0.1.el9_3.x86_64 13/34
Installing : samba-winbind-modules-4.18.6-102.0.1.el9_3.x86_64 14/34
Installing : samba-ldb-ldap-modules-4.18.6-102.0.1.el9_3.x86_64 15/34
Installing : samba-common-tools-4.18.6-102.0.1.el9_3.x86_64 16/34
Installing : samba-4.18.6-102.0.1.el9_3.x86_64 17/34
Running scriptlet: samba-4.18.6-102.0.1.el9_3.x86_64 17/34
Installing : python3-tevent-0.14.1-2.el9.x86_64 18/34
Installing : python3-dns-2.3.0-2.el9.noarch 19/34
Installing : python3-samba-4.18.6-102.0.1.el9_3.x86_64 20/34
Installing : python3-samba-dc-4.18.6-102.0.1.el9_3.x86_64 21/34
Installing : samba-tools-4.18.6-102.0.1.el9_3.x86_64 22/34
Running scriptlet: samba-winbind-4.18.6-102.0.1.el9_3.x86_64 23/34
Installing : samba-winbind-4.18.6-102.0.1.el9_3.x86_64 23/34
Running scriptlet: samba-winbind-4.18.6-102.0.1.el9_3.x86_64 23/34
Installing : samba-winbind-clients-4.18.6-102.0.1.el9_3.x86_64 24/34
Installing : samba-winbind-krb5-locator-4.18.6-102.0.1.el9_3.x86_64 25/34
Running scriptlet: samba-winbind-krb5-locator-4.18.6-102.0.1.el9_3.x86_64 25/34
Running scriptlet: samba-usershares-4.18.6-102.0.1.el9_3.x86_64 26/34
Installing : samba-usershares-4.18.6-102.0.1.el9_3.x86_64 26/34
Installing : samba-vfs-iouring-4.18.6-102.0.1.el9_3.x86_64 27/34
Installing : samba-krb5-printing-4.18.6-102.0.1.el9_3.x86_64 28/34
Running scriptlet: samba-krb5-printing-4.18.6-102.0.1.el9_3.x86_64 28/34
Installing : samba-winexe-4.18.6-102.0.1.el9_3.x86_64 29/34
Cleanup : libsmbclient-4.18.6-101.el9_3.x86_64 30/34
Cleanup : samba-client-libs-4.18.6-101.el9_3.x86_64 31/34
Cleanup : samba-common-libs-4.18.6-101.el9_3.x86_64 32/34
Cleanup : libwbclient-4.18.6-101.el9_3.x86_64 33/34
Cleanup : samba-common-4.18.6-101.el9_3.noarch 34/34
Running scriptlet: samba-common-4.18.6-101.el9_3.noarch 34/34
Verifying : libnetapi-4.18.6-102.0.1.el9_3.x86_64 1/34
Verifying : python3-dns-2.3.0-2.el9.noarch 2/34
Verifying : python3-ldb-2.7.2-2.el9.x86_64 3/34
Verifying : python3-samba-4.18.6-102.0.1.el9_3.x86_64 4/34
Verifying : python3-samba-dc-4.18.6-102.0.1.el9_3.x86_64 5/34
Verifying : python3-talloc-2.4.0-2.el9.x86_64 6/34
Verifying : python3-tdb-1.4.8-2.el9.x86_64 7/34
Verifying : python3-tevent-0.14.1-2.el9.x86_64 8/34
Verifying : samba-4.18.6-102.0.1.el9_3.x86_64 9/34
Verifying : samba-common-tools-4.18.6-102.0.1.el9_3.x86_64 10/34
Verifying : samba-dc-libs-4.18.6-102.0.1.el9_3.x86_64 11/34
Verifying : samba-dcerpc-4.18.6-102.0.1.el9_3.x86_64 12/34
Verifying : samba-ldb-ldap-modules-4.18.6-102.0.1.el9_3.x86_64 13/34
Verifying : samba-libs-4.18.6-102.0.1.el9_3.x86_64 14/34
Verifying : samba-tools-4.18.6-102.0.1.el9_3.x86_64 15/34
Verifying : samba-usershares-4.18.6-102.0.1.el9_3.x86_64 16/34
Verifying : samba-winbind-4.18.6-102.0.1.el9_3.x86_64 17/34
Verifying : samba-winbind-modules-4.18.6-102.0.1.el9_3.x86_64 18/34
Verifying : samba-client-4.18.6-102.0.1.el9_3.x86_64 19/34
Verifying : samba-krb5-printing-4.18.6-102.0.1.el9_3.x86_64 20/34
Verifying : samba-vfs-iouring-4.18.6-102.0.1.el9_3.x86_64 21/34
Verifying : samba-winbind-clients-4.18.6-102.0.1.el9_3.x86_64 22/34
Verifying : samba-winbind-krb5-locator-4.18.6-102.0.1.el9_3.x86_64 23/34
Verifying : samba-winexe-4.18.6-102.0.1.el9_3.x86_64 24/34
Verifying : libsmbclient-4.18.6-102.0.1.el9_3.x86_64 25/34
Verifying : libsmbclient-4.18.6-101.el9_3.x86_64 26/34
Verifying : libwbclient-4.18.6-102.0.1.el9_3.x86_64 27/34
Verifying : libwbclient-4.18.6-101.el9_3.x86_64 28/34
Verifying : samba-client-libs-4.18.6-102.0.1.el9_3.x86_64 29/34
Verifying : samba-client-libs-4.18.6-101.el9_3.x86_64 30/34
Verifying : samba-common-4.18.6-102.0.1.el9_3.noarch 31/34
Verifying : samba-common-4.18.6-101.el9_3.noarch 32/34
Verifying : samba-common-libs-4.18.6-102.0.1.el9_3.x86_64 33/34
Verifying : samba-common-libs-4.18.6-101.el9_3.x86_64 34/34
Upgraded:
libsmbclient-4.18.6-102.0.1.el9_3.x86_64 libwbclient-4.18.6-102.0.1.el9_3.x86_64 samba-client-libs-4.18.6-102.0.1.el9_3.x86_64 samba-common-4.18.6-102.0.1.el9_3.noarch
samba-common-libs-4.18.6-102.0.1.el9_3.x86_64
Installed:
libnetapi-4.18.6-102.0.1.el9_3.x86_64 python3-dns-2.3.0-2.el9.noarch python3-ldb-2.7.2-2.el9.x86_64 python3-samba-4.18.6-102.0.1.el9_3.x86_64
python3-samba-dc-4.18.6-102.0.1.el9_3.x86_64 python3-talloc-2.4.0-2.el9.x86_64 python3-tdb-1.4.8-2.el9.x86_64 python3-tevent-0.14.1-2.el9.x86_64
samba-4.18.6-102.0.1.el9_3.x86_64 samba-client-4.18.6-102.0.1.el9_3.x86_64 samba-common-tools-4.18.6-102.0.1.el9_3.x86_64 samba-dc-libs-4.18.6-102.0.1.el9_3.x86_64
samba-dcerpc-4.18.6-102.0.1.el9_3.x86_64 samba-krb5-printing-4.18.6-102.0.1.el9_3.x86_64 samba-ldb-ldap-modules-4.18.6-102.0.1.el9_3.x86_64 samba-libs-4.18.6-102.0.1.el9_3.x86_64
samba-tools-4.18.6-102.0.1.el9_3.x86_64 samba-usershares-4.18.6-102.0.1.el9_3.x86_64 samba-vfs-iouring-4.18.6-102.0.1.el9_3.x86_64 samba-winbind-4.18.6-102.0.1.el9_3.x86_64
samba-winbind-clients-4.18.6-102.0.1.el9_3.x86_64 samba-winbind-krb5-locator-4.18.6-102.0.1.el9_3.x86_64 samba-winbind-modules-4.18.6-102.0.1.el9_3.x86_64 samba-winexe-4.18.6-102.0.1.el9_3.x86_64
Complete!
Step3: Start, enable and check the status of smb by using the following command
[root@linuxhelp ~]# systemctl start smb
[root@linuxhelp ~]# systemctl enable smb
Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.
[root@linuxhelp ~]# systemctl status smb
● smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; preset: disabled)
Active: active (running) since Sun 2024-04-07 21:23:41 IST; 6s ago
Docs: man:smbd(8)
man:samba(7)
man:smb.conf(5)
Main PID: 10090 (smbd)
Status: "smbd: ready to serve connections..."
Tasks: 3 (limit: 21739)
Memory: 8.2M
CPU: 53ms
CGroup: /system.slice/smb.service
├─10090 /usr/sbin/smbd --foreground --no-process-group
├─10100 /usr/sbin/smbd --foreground --no-process-group
└─10102 /usr/sbin/smbd --foreground --no-process-group
Apr 07 21:23:41 linuxhelp systemd[1]: Starting Samba SMB Daemon...
Apr 07 21:23:41 linuxhelp smbd[10090]: [2024/04/07 21:23:41.244756, 0] ../../source3/smbd/server.c:1746(main)
Apr 07 21:23:41 linuxhelp smbd[10090]: smbd version 4.18.6 started.
Apr 07 21:23:41 linuxhelp smbd[10090]: Copyright Andrew Tridgell and the Samba Team 1992-2023
Apr 07 21:23:41 linuxhelp systemd[1]: Started Samba SMB Daemon.
Step4: Create Directory in Root by using the below command.
[root@linuxhelp ~]# mkdir /share1
[root@linuxhelp ~]# mkdir /share2
[root@linuxhelp ~]# mkdir /share3
Step5: Create Users by using the below command.
[root@linuxhelp ~]# adduser --system user1
[root@linuxhelp ~]# adduser --system user2
[root@linuxhelp ~]# adduser --system user3
Step 6: Create Groups by using the below command.
[root@linuxhelp ~]# groupadd sambagroup1
[root@linuxhelp ~]# groupadd sambagroup2
Step 7: Add the Users in their Respective Groups by using the below command.
[root@linuxhelp ~]# usermod -a -G sambagroup1 user1
[root@linuxhelp ~]# usermod -a -G sambagroup1 user3
[root@linuxhelp ~]# usermod -a -G sambagroup2 user2
[root@linuxhelp ~]# usermod -a -G sambagroup2 user3
Step 8: Add the user to samba and create password by using the below command.
[root@linuxhelp ~]# smbpasswd -a user1
New SMB password:
Retype new SMB password:
Added user user1.
[root@linuxhelp ~]# smbpasswd -a user2
New SMB password:
Retype new SMB password:
Added user user2.
[root@linuxhelp ~]# smbpasswd -a user3
New SMB password:
Retype new SMB password:
Added user user3.
Step 9: Enable the sambausers by using the below command.
[root@linuxhelp ~]# smbpasswd -e user1
Enabled user user1.
[root@linuxhelp ~]# smbpasswd -e user2
Enabled user user2.
[root@linuxhelp ~]# smbpasswd -e user3
Enabled user user3.
Step 10: Change the SELinux context for files by using the below command.
[root@linuxhelp ~]# chcon -Rt samba_share_t /share1
[root@linuxhelp ~]# chcon -Rt samba_share_t /share2
[root@linuxhelp ~]# chcon -Rt samba_share_t /share3
Step 11: Stop and Disable Firewall by using the below command.
[root@linuxhelp ~]# systemctl stop firewalld
[root@linuxhelp ~]# systemctl disable firewalld
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
Step 12: Grant Permission by using the below command.
[root@linuxhelp ~]# chmod -R 777 /share1/
[root@linuxhelp ~]# chmod -R 777 /share2/
[root@linuxhelp ~]# chmod -R 777 /share3/
Step 13: Create files inside the Directory by using the below command.
[root@linuxhelp ~]# touch /share1/file1
[root@linuxhelp ~]# touch /share2/file2
[root@linuxhelp ~]# touch /share3/file3
Step 14: Edit and make insert the configuration by using the below command.
[root@linuxhelp ~]# vim /etc/samba/smb.conf
Add those following Lines
[share1]
path = /share1
valid users = user2, @sambagroup1
read list = user2
write list = @sambagroup1
browsable = yes
[share2]
path = /share2
valid users = user1, @sambagroup2
read list = user1
write list = @sambagroup2
browsable = yes
[share3]
path = /share3
valid users = user2, user3
read list = user2,user3
write list = user3
browsable = yes
invalid users = user1
Step 15: Restart the services by using the below command.
[root@linuxhelp ~]# systemctl restart smb nmb
Step 16: Go to Windows Machine and Login with user credentials as shown in the below image
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the Permission-based configuration in Samba on Oracle Linux 9.3.Your feedback is much welcome.