题目
按照以下要求完成相关任务:
1、在Windows中创建共享文件夹,利用Centos下客户端完成挂载;
2、在CentOS中利用samba创建本宿舍共享文件夹,要求只有宿舍长能够对文件夹进行读写,其他宿舍成员只能读取;
3、在CentOS中利用NFS将samba创建的共享文件夹共享出来,要求只读。
具体操作步骤
1.安装探究所需要的工具
yum install -y samba samba-client rpcbind nfs-utils
yum install -y cifs-utils
如果不是最小化安装则不需要安装该工具,桌面版centos不需要安装此工具,CIFS是实现文件共享服务的一种文件系统,主要用于实现windows系统中的文件共享
2.关闭防火墙和SElinux
systemctl stop firewalld
setenforce 0
3.设置共享文件
3.1在C盘下创建文件share
3.2将文件设置为共享文件
右击文件->属性->共享->下面的共享->选择账户
3.3如果使用win10的话参看以下链接
[win10设置]
https://blog.csdn.net/u010886217/article/details/102781172?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-2
报错查看以下链接
1.https://blog.csdn.net/whatday/article/details/90763652
2.https://blog.csdn.net/su_use/article/details/80570269
4.挂载文件完成探究的第一个问题
mount -t cifs -o username='Administrator' //192.168.192.129/share /mnt/
点击回车后会输入密码即为改账户的密码也就是window对应账户的密码
5.创建文件设置权限
mkdir /sushe
chmod -R 777 /sushe
6.创建用户并设置Samba用户密码是123456自己设置
[root@localhost /]# useradd sushezhang
[root@localhost /]# useradd sheyuan
[root@localhost /]# smbpasswd -a sushezhang
New SMB password:
Retype new SMB password:
Added user sushezhang.
[root@localhost /]# smbpasswd -a sheyuan
New SMB password:
Retype new SMB password:
Added user sheyuan.
7.修改配置文件
vim /etc/samba/smb.conf
添加如下配置
[sushe]
comment = susheziliao
path = /sushe
readonly = yes
write list = sushezhang
8.进行测试,完成探究第二问
testparm
systemctl restart smb nmb
使用社员的账号 mkdir sheyuan 创建文件夹
[root@localhost ~]# smbclient -c"mkdir sheyuan" //192.168.192.131/sushe -U sheyuan%123456
出现该报错说明该账号是只读属性,表明上述配置成功
NT_STATUS_ACCESS_DENIED making remote directory \sheyuan
再次使用社长的账号 mkdir sushezhang 创建文件夹,没有提示说明创建成功
[root@localhost ~]# smbclient -c"mkdir suzhezhang" //192.168.192.131/sushe -U sushezhang%123456
9.使用NFS完成第三问
9.1开启服务
systemctl start rpcbind nfs
查看
systemctl is-active rpcbind nfs
9.2修改配置文件
vim /etc/exports
/sushe 192.168.192.0/24(insecure,ro)
9.3重启测试
systemctl restart rpcbind nfs
查看分享的文件
showmount -e 192.168.192.131
挂载
mount 192.168.192.131:/sushe /mnt
进入到mnt,出现以下情况说明是只读属性
[root@localhost mnt]# touch aa.txt
touch: cannot touch ‘aa.txt’: Read-only file system