How to Install Samba and share a directory on Centos

For installing samba, we download it’s package and install it through yum or rpm.
If you are installing through yum, then run this command.

#yum install samba

and if you are installing through rpm then run this command.

#rpm -ivh

Note-if you are installing through rpm, then it’s very important you also install it’s all dependecies.

Now you create a directory which you want to share.


Now you set it’s permission

#chmod -R 777

After that you open it’s configuration file and make some changes here.

#vi /etc/samba/smb.conf

Uncommant both lines

interfaces = lo eth1
hosts allow = 127. 192.168.

Now you copy these lines and paste them at the last of the configuration file.

; [public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = +staff

Now you uncommant all lines and make changes as below.

[dir name]
comment = this is samba
path = dir name (Complete path of your directory)
public = yes
writable = yes
printable = no
browseable = yes
valid users = user-name (All user name separates by ,”camma” )

Now you create samba user and password for user using the following command.

#smbpasswd -a

Now you add this user in configuration file in valid user.

After that, run these commands.

#chcon -R -t samba_share_t
#service smb restart
#chkconfig smb on

Now you are ready for login in samba and for login, run this command.

#smbclient //servername or IP/ -U
(Here Enter Your Samba Password)

Comments on this entry are closed.