Setup CentOS Samba Standalone Server

Getting started

This explains the installation of a Samba fileserver on CentOS and how to configure it to share files over the SMB protocol as well as how to add users. Samba is configured as a standalone server, not as a domain controller.

  1. Installing Samba
    Connect to your server on the shell and install the Samba packages:
    yum install cups-libs samba samba-common
    Edit the smb.conf file:

    vi /etc/samba/smb.conf
    Make sure you see the following lines in the [global] section:
    [...]  
    # Backend to store user information in. New installations should
    # use either tdbsam or ldapsam. smbpasswd is available for backwards
    # compatibility. tdbsam requires no further configuration.
    security = user
    passdb backend = tdbsam
    [...]
    This enables Linux system users to log in to the Samba server.

    Then create the system startup links for Samba and start it:

    chkconfig --levels 235 smb on
    /etc/init.d/smb start
  2. Adding Samba Shares

    Now I will add a share that is accessible by all users.
    Create the directory for sharing the files and change the group to the users group:

    mkdir -p /home/shares/allusers
    chown -R root:users /home/shares/allusers/      (changes the owner or group)
    chmod -R ug+rwx,o+rx-w /home/shares/allusers/
    At the end of the file /etc/samba/smb.conf add the following lines:
    vi /etc/samba/smb.conf
    [...]
    [allusers]
    comment = All Users
    path = /home/shares/allusers
    valid users = @users
    force group = users
    create mask = 0660
    directory mask = 0771
    writable = yes
    
    [sipxpbx]
    comment = sipX Share
    path = /etc/sipxpbx
    ;valid users = admin
    ;public = yes
    writable = yes
    [sipxdata]
    comment = sipX Data
    path = /var/sipxdata
    ;valid users = admin
    ;public = yes
    writable = yes
    [wwwDoc]
    comment = Document Root
    path = /usr/share/www/doc
    ;valid users = admin
    ;public = no
    writable = yes
    Now we restart Samba:
    /etc/init.d/smb restart
  3. Adding and Managing Users
    I will add a user named tom You can add as many users as you need in the same way, just replace the username tom with the desired username in the commands.
    useradd tom -m -G users
    Set a password for tom in the Linux system user database. If the user tom should not be able to log into the Linux system, skip this step.
    passwd tom
    -> Enter the password for the new user.

    Now add the user to the Samba user database:

    smbpasswd -a tom
    -> Enter the password for the new user.

    Now you should be able to log in from your Windows workstation with the file explorer
    (address is \\172.18.32.50\tom for tom's home directory) using the username tom and the chosen password and store files on the Linux server either in tom's home directory or in the public shared directory.