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.
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:
- Edit samba server
# vi /etc/samba/smb.conf
[global] netbios name = server2 workgroup = MYGROUP server string = Samba Server security = user
- At the end of the file add the following:
[tmp2] path = /tmp2 writeable = yes valid users = root, sambauser1
- Save and close the file.
- Test the syntax with this command:
- Add the root user to samba users.
# smbpasswd -a root
- Add sambauser1 to linux users
# useradd sambauser1
- Create a password for sambauser1
# smbpasswd -a sambauser1
- Make sure the firewall does not block access to samba port by running:
Allow (samba) as "Trusted Services"
- Create the tmp2 directory.
# mkdir /tmp2
# chmod 1777 /tmp2
- Restart samab
# service smb restart
- 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
- To mount the samba driver
# smbclient -L server2.example.com -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.