每天 Shaarli
假设共享目录是/srv/data/
samba配置文件在/etc/samba/smb.conf
建 Linux 用户(如果还没建)
useradd -m -s /bin/bash scientistzjf
passwd scientistzjf
加 Samba 密码(Windows 连接用这个)
smbpasswd -a scientistzjf
smbpasswd -e scientistzjf
配置文件:
[global]
workgroup = WORKGROUP
server string = ZJF Samba
security = user
# 用户不存在时映射为匿名
map to guest = Bad User
guest account = nobody
# 日志
log file = /var/log/samba/log.%m
max log size = 1000
# Windows 兼容性
vfs objects = acl_xattr
map acl inherit = yes
store dos attributes = yes
########################################
# 管理员总入口(不影响排序,可选)
########################################
[srv-data]
comment = Full access for scientistzjf
path = /srv/data
browseable = yes
guest ok = no
valid users = scientistzjf
read only = no
force user = scientistzjf
force group = scientistzjf
create mask = 0777
directory mask = 0777
########################################
# 以下共享名 = 目录名(Windows 排序友好)
########################################
[000-Video]
path = /srv/data/000-Video
browseable = yes
guest ok = yes
read only = yes
[001-Music]
path = /srv/data/001-Music
browseable = yes
guest ok = yes
read only = yes
[002-Documents]
path = /srv/data/002-Documents
browseable = yes
guest ok = yes
read only = yes
write list = scientistzjf, nobody
[003-E_Books]
path = /srv/data/003-E_Books
browseable = yes
guest ok = yes
read only = yes
[004-Android_APPs]
path = /srv/data/004-Android_APPs
browseable = yes
guest ok = yes
read only = yes
[005-Tools]
path = /srv/data/005-Tools
browseable = yes
guest ok = yes
read only = yes
[006-Downloads]
path = /srv/data/006-Downloads
browseable = yes
guest ok = yes
read only = yes
write list = scientistzjf, nobody
检查与重启 Samba
testparm
systemctl restart smbd
systemctl restart nmbd # 有些系统需要
测试smb连接
smbclient -L localhost -N