1.需求:
建立两个用户(zx,zxadmin),zxadmin能访问所有目录,zx只能访问指定目录。
2.安装smb
[[email protected] /]# yum install samba -y
3.创建用户(zxamin为主账户,zx为普通账户,zx属于zxadmin组),并把账户转化为smb用户
[[email protected] /]# useradd zxadmin [[email protected] /]# useradd -G zxadmin zx
[[email protected] /]# smbpasswd -a zxadmin New SMB password: Retype new SMB password: Added user zxadmin. [[email protected] /]# smbpasswd -a zx New SMB password: Retype new SMB password: Added user zx.
4.创建smb目录(smb目录属于zxadmin用户,并且设置smb目录权限为770)
[[email protected] /]# mkdir /data [[email protected] data]# mkdir /data/smb1 [[email protected] data]# mkdir /data/smb2
[[email protected] /]# chown -R zxadmin.zxadmin /data/
[[email protected] /]# chmod -R 770 /data/
5.配置smb.conf(vim /etc/samba/smb.conf)
[smb1] comment = smb1 path = /data/smb1 browseable = yes valid users = zxadmin #指定zxadmin账户,此目录只能zxadmin访问 guest ok = no writable = yes [smb2] comment = smb2 path = /data/smb2 browseable = yes valid users = zxadmin,zx #指定zx和zxadmin账户,此目录为公用目录 guest ok = no writable = yes
6.启动smb服务
[[email protected] samba]# /etc/init.d/smb start Starting SMB services: [ OK ]
7.关闭防火墙和selinux
8.访问测试
时间: 2024-10-10 01:37:27