How to install and configure samba on centos 6 :
Samba is free software mainly used for file sharing between other platforms ( Windows ) using SMB/CIFS protocol .Default centos 6 installation will not include samba packages , you need install manually .Here we can see how to install and configure samba using yum.
Samba installation :
After installing Centos 6 (Centos 6 installation step by step screenshots ) and configuring network (How to setup network in centos 6)
Step 1 » Update yum repositories and packages by typing the below command
[root@localhost ~]# yum update
Step 2 » Install samba packages along with dependencies using yum
[root@localhost ~]# yum install samba
Samba configuration :
Step 3 » Create a share username and password .
[root@localhost ~]# useradd shareuser -s /sbin/nologin
Now create samba password for username shareuser using smbpasswd command .
[root@localhost ~]# smbpasswd -a shareuser
New SMB password:****
Retype new SMB password:****
Added user shareuser.
Step 4 » Create a folder called share in the root directory .
[root@localhost ~]# mkdir /share
and change the ownership for the share folder
[root@localhost ~]# chown -R shareuser:root /share/
Step 5 » open the file /etc/samba/smb.conf . ( Before editing the file , please copy the file to another location for backup ) . Add the below lines at the bottom of the file .
[share]
comment = Share
path = /share
writable = yes
valid users = shareuser
Step 6 » start samba service
[root@localhost ~]# service smb start
and type this below command to start samba service automatically while booting.
[root@localhost ~]# chkconfig --levels 235 smb on
Samba testing :
Step 7 » You can check your configuration by using testparm command
[root@localhost ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
cups options = raw
[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No
[share]
comment = Share
path = /share
valid users = shareuser
read only = No
You can see your share sections. Here by default home folders of users will be displayed . you can comment the unwanted section using “;” symbol .
For example . you can comment homes section as below and restart the service using “service smb restart”
;[homes]
;comment = Home Directories
;read only = No
;browseable = No
Now you can access share folder on windows machine by typing \samba-server-ip on run prompt . you can see your share folder after entering username and password.
Cheers ..
Thank you very much for taking the time to document and make it easy.
Thank you very much for taking the time to document and make it easy.
when i type the command this “chown -R shareuser:/root/share/”
I got the follwing error:
chown: missing operand after `shareuser:/root/share/’
Try `chown –help’ for more information.
Regards
chown -R shareuser:root /share/
Thank you for the reply.
Same error i am getting again “chown: missing operand after ‘shareuser:root/share/’
Try `chown –help’ for more information.”
Dear Hassan Ali provided you with the right command you should use chown -R shareuser:root /share/ rather than using
chown -R shareuser:root/share/. in bash command ,arguments and options should be seprated using white space. in the command provided here chown is command, -R is option and /share is argument.
when i type the command this “chown -R shareuser:/root/share/”
I got the follwing error:
chown: missing operand after `shareuser:/root/share/’
Try `chown –help’ for more information.
Regards
chown -R shareuser:root /share/
Thank you for the reply.
Same error i am getting again “chown: missing operand after ‘shareuser:root/share/’
Try `chown –help’ for more information.”
Dear Hassan Ali provided you with the right command you should use chown -R shareuser:root /share/ rather than using
chown -R shareuser:root/share/. in bash command ,arguments and options should be seprated using white space. in the command provided here chown is command, -R is option and /share is argument.
there is some space between root and /share/
yes, there command. options and arguments should be separated by a white space.
Just confirming for others that this does indeed work.
Just confirming for others that this does indeed work.
Awesome instructions. Worked perfectly on CentOS 6! (6.7) Thank you very much! Note to anyone who wants to set up home directory support. Instead of doing all of the “shareuser” commands, just edit `/etc/samba/smb.conf` and uncomment the line `valid users = %S`.
Hi, I am trying stop the windows service(tomcat) from Centos 6.8. I have installed samba-client in Centos and i hv the same userid/pwd in windows and centos. But if i use the net command, getting access denied error. Someone pls help me.
chcon -t samba_share_t /share