samba文件共享
samba文件共享
软件 | 版本 |
---|---|
samba | 4.10.16 |
节点 | IP | 系统 | 功能 | CPU | 内存 | 硬盘 |
---|---|---|---|---|---|---|
node1 | 10.80.10.1 | centos7.9 | samba | 4核心 | 8GB | 20GB |
centos7下samba服务器搭建
node1
下载安装samba:
1 | # yum install -y samba |
修改hosts:
1 | # vim /etc/hosts |
创建samba账号,用户testuser,密码123456::
1 | # useradd testuser |
修改samba配置文件:
1 | # cp /etc/samba/smb.conf{,.bak} |
启动samba,设置开机自启:
1 | # systemctl start nmb smb |
win+r打开运行,打开\\10.80.10.1:
输入用户名和密码:
1 | 用户名:testuser |
进入samba:
在testuser文件夹创建测试文件test.txt,内容为test:
在linux上查看:
1 | # cd /home/testuser/ |
创建test2.txt测试文件:
1 | # vim test2.txt |
1 | # ls |
samba服务器权限实战
node1
使用root写入的windows无法修改:
1 | # ll |
windows可以打开但无法修改test2.txt:
修改test2.txt文件权限,windows可以修改:
1 | # chown testuser:testuser test2.txt |
修改权限,使用root写入的文件windows无法打开:
1 | # chown root:root test2.txt |
添加读权限:
1 | # chmod +r test2.txt |
windows新增的文件默认是用户权限。linux上非用户权限的文件可能会无权限修改。
samba服务器读写用户区分
node1
创建samba读用户,密码123456:
1 | # useradd read |
修改samba配置文件,添加read用户:
1 | # vim /etc/samba/smb.conf |
1 | # systemctl restart nmb smb |
cmd命令清除与samba的连接,找到对应连接,然后使用以下命令删除:
1 | > net use |
重启samba:
1 | # systemctl restart nmb smb |
修改testuser家目录权限:
1 | # chmod 755 /home/testuser/ |
win+r打开运行,打开\\10.80.10.1,使用read登录:
1 | 用户名:read |
进入samba:
有读权限,没有写权限:
手动添加权限后samba也无法写入,但是linux可以使用read用户写入。