需求:
有两个用户abo和abu;
有三个文件夹:
/samba_workspace/abo/ : 用户abo可访问,拥有读写权限
/samba_workspace/abu/ : 用户abu可访问,拥有读写权限
/samba_workspace/share/ : 用户abo,abu均可访问,均拥有读写权限
步骤
安装sambaapt-get install samba
创建共享文件夹
mkdir -p /samba_workspace/abo
mkdir -p /samba_workspace/abu
mkdir -p /samba_workspace/share
新增用户
useradd abu -s /sbin/nologin
useradd abo -s /sbin/nologin
修改共享文件夹的所有者
chown -R abo:abo /samba_workspace/abo/
chown -R abu:abu /samba_workspace/abu/
chown -R abo:abo /samba_workspace/share/ //先将share的所有者设为abo,然后再用setfacl赋予abu读写权限
setfacl -R -m u:abu:rwx /samba_workspace/share/
向samba新增用户
smbpasswd -a abo
//输入密码
//确认密码
smbpasswd -a abu
//输入密码
//确认密码
修改samba的配置文件
vim /etc/samba/smb.conf
//在文件最后添加
[abo]
comment = Jimbo's folder
path = /samba_workspace/abo
browseable = yes
read only = no
create mask = 0774
directory mask = 0775
valid users = abo
[abu]
comment = Poppy's folder
path = /samba_workspace/abu
browseable = yes
read only = no
create mask = 0774
directory mask = 0775
valid users = abu
[share]
comment = Common share folder
path = /samba_workspace/share
browseable = yes
read only = no
create mask = 0774
directory mask = 0775
valid users = abu,abo
write list = abu,abo
修改完配置文件后用testparm检查下有无语法错误
testparm /etc/samba/smb.conf
重启samba服务
/etc/init.d/samba restart
在windows端验证
如果使用abo帐号登录了后,想切换成abu登录,需要先断开与samba的链接,方法如下:
来源:oschina
链接:https://my.oschina.net/u/4386652/blog/4913130