Basic Samba for CentOS

The following is a basic how-to guide for setting up Samba file sharing on CentOS. This is meant to be a simple introduction and does not include options for integrating Samba authentication with LDAP or Active Directory.

Check and see if samba is installed or not:

# rpm -qa samba

If it is not installed, then install using:

# yum install samba

# yum install samba-common

# yum install samba-client

# yum install system-config-samba

Samba configuration file is /etc/samba/smb.conf.

To set SElinux

# setsebool -P samba_enable_home_dirs 1

To Start Samba Server:

# service smb start

To Start Samba Server when the system is booted:

# chkconfig smb on

you can create samba users only from linux users who already have accounts.

Configuration Example

If you want to share the tmp2 directory with Linux and Windows computers on your network, and you want to give the root and sambauser1 read and write access, do the following:

  1. Edit samba server
    # vi /etc/samba/smb.conf
    netbios name = server2
    workgroup = MYGROUP
    server string = Samba Server
    security = user
  2. At the end of the file add the following:
    path = /tmp2
    writeable = yes
    valid users = root, sambauser1
  3. Save and close the file.
  4. Test the syntax with this command:
    # testparm
  5. Add the root user to samba users.
    # smbpasswd -a root
  6. Add sambauser1 to linux users
    # useradd sambauser1
  7. Create a password for sambauser1
    # smbpasswd -a sambauser1
  8. Make sure the firewall does not block access to samba port by running:
    # system-config-securitylevel
    Allow (samba) as "Trusted Services"
  9. Create the tmp2 directory.
    # mkdir /tmp2
    # chmod 1777 /tmp2
  10. Restart samab
    # service smb restart
  11. Make sure the samba server and the samba clients have the same workgroup, for example, if the workgroup is MYGROUP, you need to go to the samba clients(linux/windows) and make it the same workgroup name. For linux server and client computers, edit smb.conf and change workgroup = MYGROUP. For the window computer right click on mycomputer=>properties=>Computer Name=>Change=>Workgroup=>MYGROUP
  12. To mount the samba driver
    # smbclient -L -U root

If you get prompted for a password and you can see the tmp2 directory then your samba is working correctly.

To configure a printer in the smb.conf file:

# vi /etc/samba/smb.conf

[global] netbios name=server2 workgroup=MYGROUP security=share printcap name=/etc/printcap load printers=yes printing=cups
[printers] path=/var/spool/samba browsable=yes printable=yes guest ok=no writable=no

For information on integrating Samba 3 with Active Directory click here.