安装samba
chunli@CentOS->~$sudoyuminstall-ysamba chunli@CentOS->~$sudoyuminstall-ysamba-client chunli@CentOS->~$sudoyuminstall-ysamba-common chunli@CentOS->~$sudoyuminstall-ysamba-winbind chunli@CentOS->~$sudoyuminstall-ysamba-winbind-clients
创建samba用户的方式1
[root@CentOS~]#useraddshare#创建系统用户 [root@CentOS~]#smbpasswd-ashare NewSMBpassword:share RetypenewSMBpassword:share
创建samba用户的方式2
[root@CentOS~]#useraddsamba_user1 [root@CentOS~]#pdbedit-asamba_user1 newpassword:samba_user1 retypenewpassword:samba_user1
pdbedit -L #列出所有samba用户
pdbedit -L [username] 查看samba用户
pdbedit -Lv [username] 查看samba用户详细信息
mkdir/opt/smb chmodo+w/opt/smb/
#修改samba配置
[root@CentOS~]#cp/etc/samba/smb.conf/etc/samba/smb.conf.install [root@CentOS~]#>/etc/samba/smb.conf [root@CentOS~]#vim/etc/samba/smb.conf logfile=/var/log/samba/log.%m maxlogsize=50 security=user smbpasswdfile=/etc/samba/smbpasswd loadprinters=yes cupsoptions=raw createmode=0644 forcecreatemode=0644 directorymode=0755 forcedirectorymode=0755 [MyShare] path=/opt/smb/ validusers=share,samba_user1 writable=yes
#重启samba服务
[root@CentOS~]#chkconfigsmbon [root@CentOSsamba]#servicesmbrestart ShuttingdownSMBservices:[OK] StartingSMBservices:
#查看samba监听状态
[root@CentOSsamba]#netstat-utnlp|grepsmb tcp000.0.0.0:1390.0.0.0:*LISTEN10510/smbd tcp000.0.0.0:4450.0.0.0:*LISTEN10510/smbd tcp00:::139:::*LISTEN10510/smbd tcp00:::445:::*LISTEN10510/smbd [root@CentOSsamba]#
iptables -F 关闭防火墙
#windows登录samba服务器
创建文件,创建目录
Linux挂载samba服务器
chunli@CentOS->~$sudomount-tcifs//172.16.20.139/MyShare~/samba/-ousername=samba_user1,password=samba_user1 chunli@CentOS->~$mount|grep"172.16.20.139" //172.16.20.139/MyShareon/home/chunli/sambatypecifs(rw) chunli@CentOS->~$cd/home/chunli/samba/ chunli@CentOS->samba$touchtest.file touch:无法创建"test.file":权限不够 用root用户可以执行挂载,root可以写入