apt-get install samba
groupadd share
useradd share -g share -s /sbin/nologin -d /dev/null
useradd luobo -g share -s /sbin/nologin -d /dev/null
useradd tudou -g share -s /sbin/nologin -d /dev/null
mkdir -p /media/Data/Share/luobo
mkdir -p /media/Data/Share/tudou/media
chown -R share:share /media/Data/Share
chmod -R rwsrwsrwx /media/Data/Share
sambapasswd -a luobo
sambapasswd -a tudou
注意在较新的版本下,设置密码的命令已经从 sambapasswd 变为 smbpasswd
cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
vi /etc/samba/smb.conf
参考如下配置
[global]
workgroup = WORKGROUP
netbios name = MyData
server string = My SAMBA Server
security = user
map to guest = bad user
guest account = share
[Media]
path = /media/Data/share/tudou/media
read only = yes
browseable = yes
guest ok = yes
[萝卜]
path = /media/Data/share/luobo
valid users = luobo, tudou
read only = no
browseable = yes
guest ok = no
[土豆]
path = /media/Data/share/tudou
valid users = tudou
read only = no
browseable = yes
guest ok = no
如此设置了3个共享目录
[Media] 可以匿名访问,只读属性
[萝卜] 必须登陆访问,两个账号具有访问权限 luobo, tudou
[土豆] 必须登陆访问,只有一个账号具有访问权限 tudou
测试过程中用到的其他命令
Windows:
net use * /del
Linux:
/etc/group 文件包含所有组
/etc/shadow 和 /etc/passwd 文件包含系统存在的所有用户名
id 命令可以查看账号和所在组的 uid 和 gid