案例:
公共目录 public /xin ro 允许任何人匿名访问
xiaoxin1 smbdq1 /tmp/xiaoxin1 rw 不允许他人访问
xiaoxin2 smbdq2 /tmp/xiaoxin2 rw 不允许他人访问
开启服务
[root@www Desktop]# service smb start
Starting SMB services: [ OK ]
[root@www Desktop]# netstat -tupln | grep smb
tcp 0 0 :::139 :::* LISTEN 6029/smbd
tcp 0 0 :::445 :::* LISTEN 6029/smbd
[root@www Desktop]# service nmb start
Starting NMB services: [ OK ]
[root@www Desktop]# netstat -tupln | grep nmb
udp 0 0 10.106.48.255:137 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.200:137 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.201:137 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.201:137 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.255:137 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.202:137 0.0.0.0:* 6149/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.255:138 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.200:138 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.201:138 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.201:138 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.255:138 0.0.0.0:* 6149/nmbd
udp 0 0 10.106.48.202:138 0.0.0.0:* 6149/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 6149/nmbd
[root@www Desktop]# mkdir -pv /tmp/xiaoxin1
mkdir: created directory `/tmp/xiaoxin1'
[root@www Desktop]# mkdir -pv /tmp/xiaoxin2
mkdir: created directory `/tmp/xiaoxin2'
[root@www Desktop]# useradd xiaoxin1 //添加用户
[root@www Desktop]# useradd xiaoxin2
[root@www Desktop]# chown xiaoxin1.xiaoxin1 /tmp/xiaoxin1
[root@www Desktop]# chown xiaoxin2.xiaoxin2 /tmp/xiaoxin2
[root@www Desktop]# touch /tmp/xiaoxin1/xiaoxin1.txt
[root@www Desktop]# touch /tmp/xiaoxin2/xiaoxin2.txt
[root@www Desktop]# mkdir /xin //创建公共目录
[root@www Desktop]# touch /xin/public.txt
[root@www Desktop]# vim /etc/samba/smb.conf
289 [public]
290 comment = This is a public dir
291 path = /xin
292 public = yes
293 ; writable = yes
294 ; printable = no
295 ; write list = +staff
296 [smbxx1]
297 comment = This is xiaoxin1's share dir
298 path = /tmp/xiaoxin1
299 valid users=xiaoxin1
300 writable = yes
301 ; printable = no
302 ; write list = +staff
303 [smbxx2]
304 comment = This is xiaoxin2's share dir
305 path = /tmp/xiaoxin2
306 valid users=xiaoxin2
307 writable = yes
308 ; printable = no
309 ; write list = +staff
[root@www Desktop]# smbpasswd -a xiaoxin1 //设置登录密码
New SMB password:
Retype new SMB password:
Added user xiaoxin1.
[root@www Desktop]# smbpasswd -a xiaoxin2
New SMB password:
Retype new SMB password:
Added user xiaoxin2.
[root@www Desktop]# service smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
测试: