How to Configure Samba Server on CentOs 7

Configure Samba Server on  CentOs 7

This article will be a quick guide to show you guys how to setup a network share with Samba on CentOs 7 or any other similar Linux distribution like Red Hat.

Samba share allows sharing of files between the server and various different computers on the same network.

Note: The following commands will require super user privileges.

1. Install Samba: Although Samba should come preinstalled on Centos but you can install it or check if it’s installed   using the command

sudo yum install samba

 

Samba 1 (2)

2. Start services smb and nmb: 
                        sudo service smb start && sudo service nmb start

You can now check the status of these services by typing the command

sudo service smb status

Samba 2 (2)

If everything is fine you will get an output like this.

3.  Loading the services on login: We want these services to be loaded with the default multiuser runlevel, we      want these services to be running when we login.

We first check if they are already enabled

sudo systemctl list-unit-files | grep smb

The service can be enabled using command

sudo chkconfig smb on && sudo chkconfig smb on

4. Create a directory to be shared: This will be the directory that will be shared.
         sudo mkdir  /home/<user_name>/<folder_name>

5. Modify the permissions of the new directory: This will ensure that the directory is readable, writable and executable.
               sudo  chmod  –R  777  /home/<user_name>/<folder_name>
               sudo  chcon  -R  -t  samba_share_t  /home/<user_name>/<folder_name>

6. Set a password for your user in samba: <user_name> is the name you used to login to your CentOs server. Remember this will be the username and password that you will use to access the samba share.

sudo smbpasswd  -a  <user_name>

7. Edit the file “/etc/samba/smb.conf”:
          sudo nano /etc/samba/smb.conf

Samba 3 (2)

Add the following details at the end of the file
[<folder_name>]
path = /home/<user_name>/<folder_name>
         browsable = yes
         guest ok = no
         valid users= user_name
         writable = yes

Samba 4 (2)
8. Allow samba through the firewall:
       sudo firewall-cmd  –permanent  –zone=public  –add-service=samba
       sudo firewall-cmd  –reload

Samba 5

 

Leave a Reply

Your email address will not be published. Required fields are marked *