CentOSLinuxTutorials

How To Install Samba on CentOS 8

Install Samba on CentOS 8

In this tutorial, we will show you how to install the Samba on CentOS 8. For those of you who didn’t know, Samba is free and open-source software that can be used to share files, folders, and printers between Linux and Windows systems.

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 the Samba on a CentOS 8.

Prerequisites

  • A server running one of the following operating systems: CentOS 8.
  • It’s recommended that you use a fresh OS install to prevent any potential issues
  • A non-root sudo user or 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 CentOS 8

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

sudo dnf update
sudo dnf install epel-release

Step 2. Installing Samba on CentOS 8.

Now we run the command below to install Samba and its dependencies:

sudo dnf install samba samba-common samba-client

Once the installation is complete, start the Sambe service, enable it to auto-start at system boot time:

sudo systemctl start smb
sudo systemctl status smb

Step 3. Samba Configuration.

First, create a backup copy of the default Samba configuration file which comes with pre-configuration settings and various configuration directives:

cp /etc/samba/smb.conf /etc/samba/smb.conf.orig

Next, create a shared folder called shared and assign the necessary permissions and ownership:

mkdir -p /srv/samba/idroot
chmod -R 0777 /srv/samba/idroot
chown -R nobody:nobody /srv/samba/idroot
chcon -t samba_share_t /srv/samba/idroot

Now we create a new samba configuration file:

sudo nano /etc/samba/smb.conf

Add the following lines:

[global]
        workgroup = WORKGROUP
        netbios name = rhel
        security = user
...
[idroot]
        comment = Anonymous File Server Share
        path = /srv/samba/idroot
        browsable =yes
        writable = yes
        guest ok = yes
        read only = no
        force user = nobody

Save and close the file. Then, restart the Samba service to apply the changes:

sudo systemctl restart smb

To verify that the configuration is sound, run testparm command:

testparm

Output:

Load smb config files from /etc/samba/smb.conf 
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (46384) 
Unknown parameter encountered: "netbios" 
Ignoring unknown parameter "netbios" 
Processing section "[homes]" 
Processing section "[printers]" 
Processing section "[print$]" 
Processing section "[idroot]" 
Loaded services file OK. 
Server role: ROLE_STANDALONE 

Press enter to see a dump of your service definitions 

# Global parameters 
[global] 
       printcap name = cups 
       security = USER 
       idmap config * : backend = tdb 
       cups options = raw 
[homes] 
       browseable = No 
       comment = Home Directories 
       inherit acls = Yes 
       read only = No 
       valid users = %S %D%w%S 

[printers] 
       browseable = No 
       comment = All Printers 
       create mask = 0600 
       path = /var/tmp 
       printable = Yes                                                                                                                           
                                                                                                                          
[print$]                                                                                                                                
       comment = Printer Drivers                                                                                                                  
       create mask = 0664                                                                                                                         
       directory mask = 0775                                                                                                                      
       force group = @printadmin                                                                                                                  
       path = /var/lib/samba/drivers 
       write list = @printadmin root 


[idroot] 
       comment = Anonymous File Server Share 
       force user = nobody 
       guest ok = Yes 
       path = /srv/samba/idroot 
       read only = No

Step 4. Configure Firewall.

We must open the appropriate ports so that the samba-shared resources can be accessed from other machines:

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

Step 5. Accessing Samba Share Path.

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 the Samba on your CentOS 8 system. For additional help or useful information, we recommend you to 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!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button