How to Install Samba4 on CentOS 7 for File Sharing on Windows

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

20 Responses

  1. Vishwa says:

    Hi Aaron,

    Thank you for the great article. I followed all the required steps for a secure user share. In my case I had to share an existing folder structure. I have a user created for smb group and provided the required permissions for the folder as well.

    I am able to connect to the share fine as well. I am able to create new files and folders but unable open or edit the existing files in the share folder.

    Is there anything i might be missing. Thank you for the help.

    Regards,

    Vishwa

    • Aaron Kili says:

      @Vishwa

      In this case, you need to update the permissions on the directory (folder) and the files in it. Try to use the permissions in the article, something like this:

      #chmod  -R  770 /path/to/folder/
      

      The -R flag allows for recursively adding the permission bits to sub-folders and files. And this means that the user and group have read, write and execute permissions on the folder, sub-folders and files in them.

      I hope this will help, otherwise, reach us again.

      • Vishwa says:

        Hi Aaron,

        I have tried the above command on the folder I am sharing. Also this folder is within the /home/ directory, if this would need any special permissions. I created a new folder in the share as a smbuser and also compared the permissions of the new folder ( where i can create the files and edit them ) with the existing folder. There is no change in the permissions, following are the permissions i notice

        drwxrwx---.  57 root smbuser       4096 Sep 20 15:07 433.697dir (Not working)
        drwxrwx---.   3 root smbuser         23 Feb 28 13:18 test folder (newly created and working)
        

        Regards,

        Vishwadeep

        • Aaron Kili says:

          @Vishwa

          If the old/existing folder is within a users home directory(for example /home/user/old_folder), then the default permissions on /home/user will prevent you from opening or editing the existing files. Normally, the default permissions on a user’s home only allow rwx for user and the user’s group.

          You can find more information from this article: RHCSA Series: How to Manage Users and Groups in RHEL 7 – Part 3

          • Vishwa says:

            Hi Aaron,

            Thank you for the help. I figured out the issue when i was reading up the smb.config.example.

            It was the following which resolved the issue..

            Turn the samba_enable_home_dirs Boolean on if you want to share home
            # directories via Samba. Run the following command as the root user to turn this
            # Boolean on:
            # setsebool -P samba_enable_home_dirs on

            Thank you again for taking time to help me out on this.

            Regards,

            Vishwa

  2. david says:

    by following this tutotial, It asks for password in Anonymous connection
    I added in smb.conf guest only= yes and guest account = nobody and then it’s ok

    But i can create files and folders in the share and they are read-only after creation.

  3. Gustavo Cerati says:

    Running CentOS 7 and Windows 7 Professional. I followed every step listed and I’m prompted for username and password

  4. Aravind says:

    Hi,

    I have installed CentOS 7, and i done the same thing as what you done in this but secure samba is not working…

    its told login failure: unknown username and bad password

  5. Bhuepnder says:

    On Server using SAMBA and the same directory is shared on client machine via NFS, from there not able to move the images, getting error operation not permitted even tried to do it from root user.

    permission is showing nobody.

  6. AhmedEagle says:

    Great Tutorial many thanks for your efforts.

  7. David says:

    My brand new plain vanilla install of Clearos 7 in step 5 when running the “chcon” command I produces the following message:- “Cannot apply partial context to unlabelled file”.
    What am I doing wrong. I am a novice wrt Linux

  8. Luthfi says:

    in no.9 when going into the network, I can not open “centos” there is a problem “the network path was not found”

  9. julian vargas says:

    For some reason, I could not access Anonymous Folder on step No. 10. After completing the rest of the tutorial, I was able to access Anonymous Folder, Secure Folder without entering any password, and I had an extra user Folder but i could not access this one even though I enter the correct user name and password.

    Thanks for all the info you share.

    • Aaron Kili says:

      @julian

      There is probably an issue with your configuration; check whether you have used the security = user variable for User-level security. And also create a samba group and add the samba users in it.

      If it is something else then try to troubleshoot. Many thanks for the feedback.

Got something to say? Join the discussion.

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