安装samba
1 、检测samba是否安装,如果没有,那么可以使用yum来安装。至少需要安装3个软件:samba, samba-client、samba-common
[root@localhost pub]# rpm -qa | grep samba samba-winbind-clients-3.6.9-164.el6.i686 samba-client-3.6.9-164.el6.i686 samba-common-3.6.9-164.el6.i686 samba4-libs-4.0.0-58.el6.rc4.i686 samba-winbind-3.6.9-164.el6.i686 [root@localhost pub]# yum install – y samba samba-client samba-common // 如果没有,那么可以用此命令安装 |
2 、创建共享目录
[root@localhost /]# mkdir /wj // 创建目录 [root@localhost /]# chmod 777 /wj // 设置权限 |
3 、修改配置文件“/etc/samba/smb.cnf”
[root@localhost /]# gedit /etc/samba/smb.conf # ----------------------- Standalone Server Options ------------------------ # Scurity can be set to user, share(deprecated) or server(deprecated) # Backend to store user information in. New installations should # use either tdbsam or ldapsam. smbpasswd is available for backwards # compatibility. tdbsam requires no further configuration security = share // 这里默认是 user ,改为 share ,这样不用输入密码就可访问 passdb backend = tdbsam [wj] // 创建共享目录配置 comment=wj // 名字 path=/wj // 路径 read only=no // 是否只读,这里为 no ,这样用户就可以创建文件夹 guest ok=yes // 是否允许 guest 用户登录 browseable=yes // 是否可以浏览目录 |
4 、修改防火墙,打开tcp的端口137、138、139、445
[root@localhost wj]# gedit /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 138 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT [root@localhost wj]# service iptables restart iptables :将链设置为政策 ACCEPT : filter nat [ 确定 ] iptables :清除防火墙规则: [ 确定 ] iptables :正在卸载模块: [ 确定 ] iptables :应用防火墙规则: [ 确定 ] iptables :载入额外模块: nf_conntrack_ftp [ 确定 ] |
5 、启动smb服务
[root@localhost wj]# service smb start 启动 SMB 服务: [ 确定 ] |
6 、测试,在终端输入命令“testparm”,可以看到共享目录的信息
[root@localhost wj]# 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 "[wj]" WARNING: The security=share option is deprecated 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 security = SHARE log file = /var/log/samba/log.%m max log size = 50 idmap config * : backend = tdb cups options = raw [homes] comment = Home Directories read only = No browseable = No [printers] comment = All Printers path = /var/spool/samba printable = Yes print ok = Yes browseable = No [wj] comment = wj // 名字 path = /wj // 路径 read only = No // 是否只读 guest ok = Yes // 是否允许 guest 访问 |
7 、从windows测试,按下快捷键“window+r”,在弹出的窗口输入命令“smb:\\192.168.0.113”,可以看到本机的共享目录
![](http://img.blog.itpub.net/blog/2018/11/29/c811122e19d0eecb.png?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/2018/11/29/6394692dbba5c015.png?x-oss-process=style/bb)
做了一个Linux学习的平台,目前出来一个雏形,各位可以参考使用
链接: https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ 密码:n7bk
![201554yh4h83ez3000nn0u.gif](http://www.itpub.net/data/attachment/forum/201811/21/201554yh4h83ez3000nn0u.gif)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29270124/viewspace-2222070/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29270124/viewspace-2222070/