centos7建立SAMBA文件共享

1 安装SAMBA

[root@localhost ]# yum install samba
 
#查看
[root@localhost ]# rpm -qa | grep samba
samba-common-libs-4.8.3-4.el7.x86_64
samba-libs-4.8.3-4.el7.x86_64
samba-common-tools-4.8.3-4.el7.x86_64
samba-common-4.8.3-4.el7.noarch
samba-client-libs-4.8.3-4.el7.x86_64
samba-4.8.3-4.el7.x86_64
samba-client-4.8.3-4.el7.x86_64

2 配置服务

vi /etc/samba/smb.conf

配置如下:

# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
        workgroup = SAMBA
        security = user
        map to guest = Bad User   ##把所有不能识别的用户都map到guest

        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


[hd_share]                              ##添加
        path = /hd_share
        comment = hw_share
        public = yes
        writable = yes
        browseable = yes
        guest ok = yes
        valid users = root,wm        ##访问用户
        available = yes

3 关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

4 关闭selinux

cat /etc/selinux/config

编辑:SELINUX=disabled

5 重启服务

systemctl restart smb.service
service smb status         //查看samba服务状态

6 win下SMB支持开启

win10下打开smb1.0访问服务:
控制面板->程序->启用或关闭windows功能->勾选:SMB1.0/CIFS文件共享支持

7 linux下测试samba服务

  1. 创建和删除用户
[root@rtl-host ~]# smbpasswd -a zwj   #创建zwj用户
[root@rtl-host hd_share]# userdel zwj   #删除zwj用户
[root@rtl-host hd_share]# cat /etc/passwd    #查询linux当前用户

  1. samba用户查询
pdbedit -L
  1. 用户权限
-rw------- (600) -- 只有属主有读写权限。
-rw-r--r-- (644) -- 只有属主有读写权限;而属组用户和其他用户只有读权限。
-rwx------ (700) -- 只有属主有读、写、执行权限。
-rwxr-xr-x (755) -- 属主有读、写、执行权限;而属组用户和其他用户只有读、执行权限。
-rwx--x--x (711) -- 属主有读、写、执行权限;而属组用户和其他用户只有执行权限。
-rw-rw-rw- (666) -- 所有用户都有文件读、写权限。
-rwxrwxrwx (777) -- 所有用户都有读、写、执行权限。
  1. 测试用户连接
[root@rtl-host ~]# smbclient -L 192.168.1.7 -U ryy
Enter SAMBA\ryy's password: 

        Sharename       Type      Comment
        ---------       ----      -------
        print$          Disk      Printer Drivers
        hd_share        Disk      hw_server0_share
        public_dir      Disk      
        IPC$            IPC       IPC Service (Samba 4.10.4)
        ryy             Disk      Home Directories
Reconnecting with SMB1 for workgroup listing.

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------
[root@rtl-host ~]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值