# yum -y install samba
# groupadd -r admins
# useradd -s /sbin/nologin -G admins smb1
# useradd -s /sbin/nologin -G admins smb2
# id smb1 && id smb2
uid=1005(smb1) gid=1005(smb1) groups=1005(smb1),994(admins)
uid=1003(smb2) gid=1003(smb2) groups=1003(smb2),994(admins)
# smbpasswd -a smb1
New SMB password: #123456
Retype new SMB password:
Added user smb1.
# smbpasswd -a smb2
New SMB password: #654321
Retype new SMB password:
Added user smb2.
# pdbedit -L # 查看用户列表
smb1:1005:
smb2:1003:
# mkdir /www
# chgrp admins /www
# chmod 2775 /www
# vi /etc/samba/smb.conf
#在最下面添加即可
[share]
#配置默认所有用户只可读
path = /www
write list = @admins #组admins列表用户不但可读,还可写
# systemctl enable --now smb nmb
# yum -y install cifs-utils
# mkdir /mnt/smb{1,2} -pv
mkdir: created directory '/mnt/smb1'
mkdir: created directory '/mnt/smb2'
# mount -o username=smb1 //10.0.0.7/share /mnt/smb1
Password for smb1@//10.0.0.7/share: ******
# mount -o username=smb2 //10.0.0.7/share /mnt/smb2
Password for smb2@//10.0.0.7/share: ******
# df -h
tmpfs 376M 0 376M 0% /run/user/0
//10.0.0.7/share 50G 1.7G 49G 4% /mnt/smb1
//10.0.0.7/share 50G 1.7G 49G 4% /mnt/smb2
#可写测试
# touch /mnt/smb1/smb1file.txt
# touch /mnt/smb2/smb2file.txt
# echo "hello smb1" > /mnt/smb1/smb1file.txt
# echo "hello smb2" > /mnt/smb2/smb2file.txt
# 可读测试
# cat /mnt/smb1/smb1file.txt
hello smb1
# cat /mnt/smb2/smb2file.txt
hello smb2
手机扫一扫
移动阅读更方便
你可能感兴趣的文章