实验要求:
Samba文件共享服务配置与访问,配置访问用户以及相应权限。
Tips:创建共享目录/test和/share,并且分别在/test下创建文件tf1(只读)tf2(读写) 在/share 下创建文件pf1(只读)和pf2(读写)
1、挂载本地yum源
[[email protected] /]# mkdir /media/cdrom [[email protected] /]# mount /dev/cdrom /media/cdrom/ [[email protected] /]# vim /etc/yum.repos.d/rhel-source.repo rhel-source] name=Red Hat Enterprise Linux $releasever - $basearch - Source baseurl=file:///media/cdrom enabled=1
2、关闭Selinux 和 IPtables
[[email protected] /]# vim /etc/selinux/config //路径 [[email protected] /]# setenforce 0 //临时关闭Selinux [[email protected] /]# /etc/init.d/iptables stop //关闭防火墙
3、安装samba服务
[[email protected] /]# yum install samba -y
4、创建共享用户
[[email protected] /]# smbpasswd -a smb [[email protected] /]# smbpasswd -a smb
5、修改配置文件
[[email protected] /]# vim /etc/samba/smb.conf workgroup = WORKGROUP //Win需要修改为工作组 server string = Samba Server Version %v security = user //可以改为everyone passdb backend = tdbsam [test] path = /test public = yes writeable = yes valid users = smb [share] path = /share public = yes writeable = yes valid users = smb
6、创建本地共享目录和文件权限
[[email protected] /]# mkdir /test /share [[email protected] /]# chown -R smb.smb /test/ /share/ [[email protected] test]# touch tp1 tp2 [[email protected] test]# chmod 444 tp1 [[email protected] test]# chmod 666 tp2 [[email protected] test]# echo "111" > /test/tp1 //ceshi 文本 [[email protected] test]# echo "222" > /test/tp2
[[email protected] test]# service smb restart //开启服务 测试
时间: 2024-10-13 00:54:08