samba 建立centos7 和win10之间共享文件夹

第一步:安装samba服务
》yum install samba
第二步:启动samba服务
》systemctl start smb
查看samba的状态
》systemctl status smb
看到Active就说明在运行中了
第三步:关闭防火墙
》systemctl stop firewalld.service //停止服务
》systemctl disable firewalld.service //关闭开机启动
同时还有这一步
设置SELINUX=disabled(需要重启电脑)
# vi /etc/selinux/config文件中设置SELINUX=disabled ,然后重启服务器。
第四步:需要添加一个用户来访问文件
》useradd wupeng //添加用户
》passwd wupeng  //修改密码
创建samba用户
》smbpasswd -a wupeng
第五步:修改samba的配置文件
》vi /etc/samba/smb.conf //进入配置文件
5.1将global中进行一下全局配置更改:
    workgroup = WORKGROUP//定义工作组,也就是windows中的工作组概念
security = user //安全认证方式采用user方式
ntlm auth = yes //否则windows7访问用户会认证失败
5.2在conf中添加新的用户配置(让4的配置生效)
[home]
   comment = home
   path = /home/wupeng
   browseable = yes
   writable = yes
修改后的smb.conf如下:
[root@code1 wupeng]# cat /etc/samba/smb.conf
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
#    workgroup = SAMBA
    workgroup = WORKGROUP
    security = user
    ntlm auth = yes
    passdb backend = tdbsam

    printing = cups
    printcap name = cups
    load printers = yes
    cups options = raw

[homes]
    comment = Home Directories
    valid users = %S, %D%w%S
    browseable = No
    read only = No
    inherit acls = Yes

[printers]
    comment = All Printers
    path = /var/tmp
    printable = Yes
    create mask = 0600
    browseable = No

[print$]
    comment = Printer Drivers
    path = /var/lib/samba/drivers
    write list = @printadmin root
    force group = @printadmin
    create mask = 0664
    directory mask = 0775

 [home]
   comment = home
   path = /home/wupeng
   browseable = yes
   writable = yes
[root@code1 wupeng]# 

第六步:设置想要共享目录的文件权限
给共享目录添加写权限,这样可以从windows向linux中写入文件。比如我这里设置\home为共享目录,那在终端输入以下命令即可
chmod -R 777 /home/wupeng (可写 w=4 可读 r=2  可执行 x=1 )
第七步:重启samba服务
》systemctl restart smb

第八步:设置samba开机重启

》chkconfig smb on

问了保险起见需要重启一下centos比较好。

上面centos里面创建好了就到win10中添加映射

输入\\192.168.59.128\home之后 先可以浏览看一下那个目录是你想要的

选择你要的文件夹之间进入,因为我定制访问的路径都是/home/wupeng下面,所以两个映射都会到这个文件下面。在Windows平台创建一个文件后可以在服务上面看到对应的文件

 

 

Guess you like

Origin blog.csdn.net/weixin_42575806/article/details/109595575