February 21, 2009
How to: Configure samba on CentOS 5
To share files and printers between Microsoft Windows and Linux/Unix computers.
If you selected Windows File Server Package during CentOS 5 installation, then you have installed Samba.
Check and see if samba is installed with this command:
# rpm -q samba
If it is not installed, then use these commands to install it:
# 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.
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:
- 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:
# testparm
- 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:
# system-config-securitylevel
Allow (samba) as "Trusted Services"
- Create the tmp2 directory.
# mkdir /tmp2
# chmod 1777 /tmp2
- Restart samab
# service smb restart
- 1)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=noRHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)


