温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么进行Windows与Linux CentOS7)之间的文件共享

发布时间:2021-11-03 16:14:52 来源:亿速云 阅读:276 作者:柒染 栏目:建站服务器

这篇文章给大家介绍怎么进行Windows与Linux CentOS7)之间的文件共享,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

折腾了好几天,终于搞定了,之前还以为直接拖进去虚拟机里就行,但是一直说解压错误,后面看文件大小,发现才只有原来的十分之一大,所以肯定是传输的过程中出错了。后面搜索解决方案,不能直接复制粘贴,搜索发现有以下三种方式:

  1. 安装 samba;

  2. 设置 VMware 共享目录;

  3. window 中安装 FTP 或 SSH 软件。

我主要讲的是第一种方法,第二种我自己试了一下,没成功,接下来正式开始安装!

一、安装 Samba

检查samba是否已经安装

[root@localhost ~]# rpm -qa | grep samba
samba-common-4.9.1-6.el7.noarch
samba-client-4.9.1-6.el7.x86_64
samba-4.9.1-6.el7.x86_64
samba-client-libs-4.9.1-6.el7.x86_64
samba-common-tools-4.9.1-6.el7.x86_64
samba-common-libs-4.9.1-6.el7.x86_64
samba-libs-4.9.1-6.el7.x86_64

注意:我是已经安装好了的,所以才会有如上的显示,如果未安装,则没有上面的显示。一般安装 CentOS 7 就会默认带有 Samba 的安装包,所以只需要执行一下命令:

yum -y install samba samba-client samba-common

这个命令既安装了 Samba 也安装了客户端 samba-client,所以再次检查安装结果就会跟我的一样了,有差别的只有版本号不同。

[root@localhost ~]# rpm -qa | grep samba
samba-common-4.9.1-6.el7.noarch
samba-client-4.9.1-6.el7.x86_64
samba-4.9.1-6.el7.x86_64
samba-client-libs-4.9.1-6.el7.x86_64
samba-common-tools-4.9.1-6.el7.x86_64
samba-common-libs-4.9.1-6.el7.x86_64
samba-libs-4.9.1-6.el7.x86_64

二、配置 samba

1.关闭 SELINUX

[root@localhost ~]# vi /etc/sysconfig/selinux

如下所示:

修改下边红字部分

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

3.关闭防火墙

[root@localhost ~]# systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

4.重启计算机

[root@localhost ~]# shutdown -r now

5.创建共享目录

[root@localhost home]# mkdir -p /home/share/software

6.创建共享用户组

[root@localhost home]# groupadd share

7.创建共享用户

[root@localhost home]# useradd -g share -s /sbin/nologin share

8.设置共享目录权限

[root@localhost home]# chown -R share:share /home/share/software

9.修改共享用户密码

[root@localhost home]# /bin/smbpasswd -a share

New SMB password:

Retype new SMB password:

Added user share.

10.修改 samba 配置文件

[root@localhost share]# vi /etc/samba/smb.conf

11.配置文件说明如下

[global] #全局变量

? workgroup = WORKGROUP #工作组

? security = user #登陆才可访问共享

? passdb backend = tdbsam

? printing = cups

? printcap name = cups

? load printers = yes

? cups options = raw

[software] #显示的共享目录名

? path = /home/share/software #共享目录路径

? comment = Software Directories #共享目录描述

? writeable = Yes #共享目录可写入

? write list = share #有写入权限的用户

? valid users = share #共享目录的用户

? browseable = Yes #是否可浏览文件

? read #是否只读

? inherit acls = No

注意:自己写的时候可以复制上面的 [software] 里的内容,但是必须要把 # 号后面的内容删除掉,这里是为了跟你说明是用来干什么的,实际文件里不要带这些注释说明,否则会报错!我就是一开始不知道,导致出错的!

12.修改完配置文件后,需要先运行一下(这个是检查 smb.conf 有没有错误的命令):

[root@localhost home]# testparm

看有没有什么错误,我之前报的如下的错误:

错误一:

rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)

见到如上的错误,就得继续以下的修改:

[root@localhost ~]# vim /etc/security/limits.conf

root - nofile 16384

root指root用户 如果想都所有用户生效,把root替换为 * 即可!我是设置的 * 下面是配置文件内容

\#subdirectory, but a user specific setting here can be overriden only
#with a user specific setting in the subdirectory.
#
#Each line describes a limit for a user in the form:
#

#
#Where:
# can be:
# - a user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
* - nofile 16384
#
# can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
# can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)

错误二:

set_variable_helper(Yes #共享目录可写入): value is not boolean! Error loading services.

这个错误就是我之前所说的,没有删掉 # 号以及 # 后面的注释的内容,当然这里不要把开头的那几行带 # 号的内容删掉了!

13.给共享目录赋予各种权限 (这里设置好了 就没有权限问题了!)

[root@localhost ~]# chmod 777 /etc/samba

[root@localhost ~]# chmon 777 /etc/samba

14.启动samba服务

[root@localhost share]# systemctl start smb

15.设置samba服务开机自启动

[root@localhost share]# systemctl enable smb

Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.

关于怎么进行Windows与Linux CentOS7)之间的文件共享就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI