码迷,mamicode.com
首页 > Windows程序 > 详细

Windows 与 Linux (CentOS7) 之间的文件共享

时间:2019-11-27 17:33:32      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:systemctl   http   str   soft   warning   iss   from   三种方式   syntax   

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 only = No #是否只读

? 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.

引自:https://blog.51cto.com/lzlutao/2367732

本文在此基础上稍作修改!

材料工程专业转行互联网开发工程师,欢迎关注。后台回复关注「1024」有惊喜哦~

技术图片

Windows 与 Linux (CentOS7) 之间的文件共享

标签:systemctl   http   str   soft   warning   iss   from   三种方式   syntax   

原文地址:https://www.cnblogs.com/reformdai/p/11943865.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!