How to install and configure Samba Server on Fedora 34

To Install And Configure Samba Server On Fedora 34

Introduction:

Samba is an incredibly powerful tool that allows you to create seamless file and printer sharing to smb/cifs clients from a linux server/desktop. with samba you can even connect that linux machine to a windows domain. this video will show you the method of how to install samba on fedora 34.

Installation process:

Step 1: Check the OS version by using the below command

[root@linuxhelp ~]# cat /etc/os-release
NAME=Fedora
VERSION="34 (Workstation Edition)"
ID=fedora
VERSION_ID=34
VERSION_CODENAME=""
PLATFORM_ID="platform:f34"
PRETTY_NAME="Fedora 34 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:34"

Step 2: Install samba server by using the below command

[root@linuxhelp ~]# dnf install samba -y
Fedora Modular 34 - x86_64 -
Fedora 34 - x86_64 - 00:00    
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                1/1
  Verifying        : samba-common-libs-2:4.14.2-1.fc34.x86_64                                                                                                     15/15

Upgraded:
  libsmbclient-2:4.14.8-0.fc34.x86_64    libwbclient-2:4.14.8-0.fc34.x86_64          samba-client-2:4.14.8-0.fc34.x86_64    samba-client-libs-2:4.14.8-0.fc34.x86_64   
  samba-common-2:4.14.8-0.fc34.noarch    samba-common-libs-2:4.14.8-0.fc34.x86_64   
Installed:
  samba-2:4.14.8-0.fc34.x86_64                     samba-common-tools-2:4.14.8-0.fc34.x86_64                     samba-libs-2:4.14.8-0.fc34.x86_64                    

Complete!

Step 3: Start SMB service by using the below command

[root@linuxhelp ~]# systemctl start smb

Step 4: Enable SMB service by using the below command

[root@linuxhelp ~]# systemctl enable smb
Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.

Step 5: Check status of SMB service by using the below command

[root@linuxhelp ~]# systemctl status smb
● smb.service - Samba SMB Daemon
     Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled)
     Active: active (running) since Wed 2021-10-27 19:59:18 EDT; 28s ago
       Docs: man:smbd(8)
             man:samba(7)
             man:smb.conf(5)
   Main PID: 20864 (smbd)
     Status: "smbd: ready to serve connections..."
      Tasks: 4 (limit: 2261)
     Memory: 24.0M
        CPU: 125ms
     CGroup: /system.slice/smb.service
             ├─20864 /usr/sbin/smbd --foreground --no-process-group
             ├─20868 /usr/sbin/smbd --foreground --no-process-group
             ├─20869 /usr/sbin/smbd --foreground --no-process-group
             └─20870 /usr/sbin/smbd --foreground --no-process-group

Oct 27 19:59:18 linuxhelp systemd[1]: Starting Samba SMB Daemon...
Oct 27 19:59:18 linuxhelp systemd[1]: Started Samba SMB Daemon.
Oct 27 19:59:18 linuxhelp smbd[20864]: [2021/10/27 19:59:18.716963,  0] ../../lib/util/become_daemon.c:135(daemon_ready)
Oct 27 19:59:18 linuxhelp smbd[20864]:   daemon_ready: daemon 'smbd' finished starting up and ready to serve connections

Step 6: Create directory by using the below commands

[root@linuxhelp ~]# mkdir /data
[root@linuxhelp ~]# mkdir /value

Step 7: Add the user by using the below command

[root@linuxhelp ~]# adduser --system shareuser
[root@linuxhelp ~]# adduser --system shareuser1

Step 8: Change the owner in this directory by using the below command

[root@linuxhelp ~]# chown -R shareuser /data
[root@linuxhelp ~]# chown -R shareuser /value

Step 9: Disable the Selinux by using the Chcon command

[root@linuxhelp ~]# chcon -Rt samba_share_t /data
[root@linuxhelp ~]# chcon -Rt samba_share_t /value

Step 10: Open the samba configuration file and add the share details by using the below command

[root@linuxhelp ~]# vi /etc/samba/smb.conf

Step 11: Create smbpassword for this users by using the below command

[root@linuxhelp ~]# smbpasswd -a shareuser
New SMB password:
Retype new SMB password:
Added user shareuser.
 [root@linuxhelp ~]# smbpasswd -a shareuser1
New SMB password:
Retype new SMB password:
Added user shareuser1.

Step 12: Enable smbpassword for this users by using the below command

[root@linuxhelp ~]# smbpasswd -e shareuser
Enabled user shareuser.
[root@linuxhelp ~]# smbpasswd -e shareuser1
Enabled user shareuser1.

Step 13 : Restart the smb and nmb services by using the below command

[root@linuxhelp ~]# systemctl restart smb nmb

Step 14: Enable the smb and nmb services by using the below command

[root@linuxhelp ~]# systemctl enable smb nmb
Created symlink /etc/systemd/system/multi-user.target.wants/nmb.service → /usr/lib/systemd/system/nmb.service.

Step 15: Open and check the SElinux configuration file by using the below command.

[root@linuxhelp ~]# vi /etc/selinux/config

Step 16: Check the firewall status by using the below command.

[root@linuxhelp ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-10-21 00:20:06 EDT; 6 days ago
       Docs: man:firewalld(1)
   Main PID: 988 (firewalld)
      Tasks: 4 (limit: 2261)
     Memory: 29.0M
        CPU: 1.478s
     CGroup: /system.slice/firewalld.service
             └─988 /usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid

Oct 21 00:20:02 fedora systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 21 00:20:06 fedora systemd[1]: Started firewalld - dynamic firewall daemon.
Oct 27 11:12:35 linuxhelp firewalld[988]: WARNING: ALREADY_ENABLED: 3128:tcp
Oct 27 11:16:05 linuxhelp firewalld[988]: WARNING: ALREADY_ENABLED: 3128:tcp

Step 17: Stop the firewall status by using the below command.

[root@linuxhelp ~]# systemctl stop firewalld

Step 18: Restart the smb and nmb services by using the below command.

[root@linuxhelp ~]# systemctl enable smb nmb

Step 19: Once completed go to run terminal type samba share id as shown in the below image.

Step 20: There will be two folders share1 and share2 as shown in the below image

Step 21: Then goto share1 and login as user1 and user2 and same for share2 as shown in the below image

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install and configure samba server on Fedora 34. Your feedback is much welcome

FAQ
Q
How to start and stop the samba server?
A
/etc/init.d/smb restart OR service smb restart
Q
How to check whether samba is already installed in the system or not?
A
Use command rpm -q samba
Q
What is the configuration file for samba?
A
it is /etc/samba/smb.conf.
Q
How to list samba users?
A
Use the command to list the samba users as "sudo pdbedit -L -v"
Q
Is there any other command for adding users to a group without deleting the old users?
A
execute command "useradd -a -G group_name user_name".