Posted in CentOS, Computers, Linux

Sharing Home Folders via Samba in CentOS 5.4

I’ve decided to re-write this post and add more details. I originally wrote it for self-reference, but figured that it could be also useful to others.

To share the home folder using the command line, we are going to do this:

  • Log on as root
  • cd /etc/samba/
  • cp smb.conf smb.conf.original (create a back-up file of smb.conf)
  • nano smb.conf (or use your favorite text editor)

Scroll down all the way to the [homes] section, check the settings, make sure they are what you need. My [home] settings look like this:

comment = Home Directories
browseable = no
writable = yes
valid users = %S
create mask = 0770
directory mask = 0770

If there isn’t a [homes] section, create it, and save your changes, close the file, and restart the smb service:

# service smb restart

If SELinux is disabled, or if it is on permissive mode, you are done. You should be able to connect to the share from a Windows, Linux, or Mac machine.

If you can’t connect to the home share, chances are that either the firewall is not allowing access to the smb service, SELinux is set to enforcing, or both, and it hasn’t been configured to allow access to the home shares. I suggest checking the status on SELinux if you are not sure; it will save you some frustration and time if you have difficulties connecting to the share.

Check and change the status on SELinux

To view the current SELinux mode:

# sestatus | grep -i mode

If its current mode says “enforcing”, you will need to run the following command in order to be able to access the home folders:

# setsebool -P samba_enable_home_dirs=1

To disable access to shared home folders, either edit the smb.conf file (path above) and remove the [homes] section, or change the settings on SELinux.

# setsebool -P samba_enable_home_dirs=0

Now you should be good to go. Restart the smb service, and connect to your home share.

For more information on SELinux, visit the CentOS Administrator Control of SELinux page, which contains more information.

I might do a little write-up with some of the basic SELinux settings…



If sharing a folder outside your home – for example, a folder that you created in “/”, you will need to add the command:

# chcon -t samba_share_t /pathToFolder

This enables sharingthe “pathToFolder” folder via Samba.


2 thoughts on “Sharing Home Folders via Samba in CentOS 5.4

  1. Good post. One correction:
    # smb service restart

    should be:
    # service smb restart


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s