CentOS7与Windows共享文件夹

2023-05-30 14:57:41 5039

一、CentOS7安装samba,用于在Linux系统上实现SMB协议的软件

在终端运行命令

yum install samba

 

二、创建准备分享的文件夹

在根目录下建立/gongxiang自定义)子目录,创建文件test.txt,并修改其权限为可读可写(777)

1.创建共享的文件夹gongxiang

[root@hadoop100 /]# mkdir /gongxiang

2.创建文件test.txt

[root@hadoop100 gongxiang]# Touch test.txt

3.修改目录权限

[root@hadoop100  /]# chmod -R 777 gongxiang

 

三、修改samba配置文件

CentOS7中,samba配置文件在/etc/samba/smb.conf

1. 进入配置文件,修改配置文件

[root@hadoop100 samba]# Vi /etc/samba/smb.conf

2. 添加如下配置

[gongxiang]

           comment = my share files

           path = /gongxiang

           writable = yes

           public = yes

image.png

3.检查配置文件是否正确

[root@hadoop100 samba]# testparm

image.png

四、添加系统用户及samba用户

1.添加系统用户

[root@hadoop100 samba]# useradd xr

2.查看系统用户是否添加成功

[root@hadoop100 samba]#  cat /etc/passwd

image.png

3.添加samba用户

[root@hadoop100 samba]# smbpasswd -a  xr

image.png


五、关闭SELinux服务以及防火墙

1.关闭防火墙

[root@hadoop100 samba]# systemctl stop firewalld

2.关闭SELinux服务

[root@hadoop100 samba]#Setenforce 0

 

六、重新启动smb和nmb服务

[root@hadoop100 samba]# systemctl restart smb

[root@hadoop100 samba]# systemctl restart nmb

 

七、linux下查看该共享文件

[root@hadoop100 samba]# smbclient //192.168.10.100/gongxiang -u xr

image.png


八、Windows下查看该共享文件

ctrl+r打开运行框,输入IP地址
便可以看到共享的文件夹gognxiang以及该文件夹内部的文件、文件夹。

image.png


提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: