系统:CentOS7,root用户 身份
文件权限:无需用户名,任何人可访问
1、安装samba
- yum -y install samba
2、查看安装状态
- rpm -qa | grep samba
查看SMB服务状态
- service smb status
3、启动SMB服务
- systemctl start smb nmb
- systemctl status smb
4、创建共享目录并更改文件夹权限
- mkdir /public
- chmod 777 /public
- chmod 777 /
5、添加samba账户
- smbpasswd -a root (将存在的系统用户添加进去)
补充:
查看samba账户 pdbedit -L
删除samba账户 pdbedit -x username
添加用户 pdbedit -a usernamete
6、配置文件smb.conf
- vi /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
passdb backend = tdbsam
printing = cups
printcap name = cups
printcap cache time = 750
cups options = raw
map to guest = Bad User
include = /etc/samba/dhcp.conf
logon path = \\%L\profiles\.msprofile
logon home = \\%L\%U\.9xprofile
logon drive = P:
usershare allow guests = Yes
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[public]
comment = test smb
path = /pubic
browseable = yes
read only = no
writable = yes
public = yes
(最后一段是定义的文件夹,path是共享路径,[public]是共享名,comment是描述)
7、重启samba服务 每次修改完必须重启
- service smb restart
- service smb status
8、测试配置文件smb.conf是否正确
- testparm
9、windows上验证
打开计算机——地址栏输入服务器地址(//ip/共享名)
//xx.xx.xx.xx/public
10、映射网络驱动器
我的电脑——菜单栏“映射网络驱动器”——逐步完成