# 安装Samba服务
```
yum install -y samba*
```
# 添加用户
```
groupadd U1 //添加用户组
groupadd U2
useradd user1 -G U1 //添加user1用户并把他加入次要组U1
useradd user2 -G U1
useradd user3 -G U2
smbpasswd -a user1 //设置user1共享密码
smbpasswd -a user2
smbpasswd -a user3
```
# 创建共享目录并设置目录权限
```
mkdir /opt/U1_share
mkdir /opt/U2_share
setfacl -m g:U1:rwx /opt/U1_share
setfacl -m g:U2:rwx /opt/U2_share
```
# 编辑Samba配置文件
vi /etc/samba/smb.conf
### 添加共享目录路径及访问权限
```
[U1]
path=/opt/U1_share
public=yes
writable=yes
[U2]
path=/opt/U2_share
public=yes
writable=yes
```
# 关闭防火墙,强制认证
```
setenforce 0
systemctl stop firewalld
systemctl disable firewalld //开机不启动防火墙
//若不关闭防火墙及SELINUX
firewall-cmd --add-service=samba --permanent //防火墙放行samba服务
firewall-cmd --reload
setsebool -P samba_export_all_ro 1
setsebool -P samba_export_all_rw 1
```
Samba服务参考:
https://www.linuxidc.com/Linux/2019-03/157288.htm