如何在CentOS 6上安装配置Samba

Samba主要用于windows与Linux之间的文件共享,使用SMB/CIFS协议。CentOS 6默认安装不包括samba软件包,所以需要我们手动进行安装。

Step 1 >> 安装samba

[root@localhost ~]# yum install samba -y

Step 2 >> 创建一个共享用户名和密码

[root@localhost ~]# useradd shareuser -s /sbin/nologin

                现在创建samba密码用户shareuser使用smbpasswd命令

[root@localhost ~]# smbpasswd -a shareuser
      New SMB password:
      Retype new SMB password:
      Added user shareuser.

Step 3 >> 创建一个名为共享的文件夹的根目录

[root@localhost ~]# mkdir /share

                并且更改共享文件夹的所有权

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

Step 4 >> 添加配置信息

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

                在文件末行添加如下,保存退出。

[share]
      comment = Share
      path = /share
      writable = yes
      valid users = shareuser

Step 5 >> 启动samba服务

[root@localhost /]# service smb start
      Starting SMB services:                                     [  OK  ]

                系统引导时自动启动samba服务

[root@localhost /]# chkconfig –levels 235 smb on

Step 6 >> 检查配置,使用 testparm

[root@localhost /]# testparm
      Load smb config files from /etc/samba/smb.conf
      rlimit_max: increasing rlimit_max (1024) to minimum   Windows limit (16384)
      Processing section "[homes]"
      Processing section "[printers]"
      Processing section "[share]"
      Loaded services file OK.
      Server role: ROLE_STANDALONE
      Press enter to see a dump of your service definitions

      [global]
      workgroup = MYGROUP
      server string = Samba Server Version %v
      log file = /var/log/samba/log.%m
      max log size = 50
      idmap config * : backend = tdb
     cups options = raw

     [homes]
     comment = Home Directories
     read only = No
     browseable = No

     [printers]
     comment = All Printers
     path = /var/spool/samba
     printable = Yes
     print ok = Yes
     browseable = No

    [share]                                            #看这
    comment = Share
    path = /share
    valid users = shareuser
    read only = No

Step 7 >> 关闭防火墙

[root@localhost /]# chkconfig –level 35 iptables off    #永久性关闭

[root@localhost /]# /etc/init.d/iptables stop                #普通关闭
      iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
      iptables: Flushing firewall rules:                                  [  OK  ]
      iptables: Unloading modules:                                     [  OK  ]

Step 8 >> 关闭selinux

[root@localhost /]# vim /etc/selinux/config

                 编辑config文件,找到SELINUX行修改为:SELINUX=disable

[root@localhost ~]# cat /etc/selinux/config

      # 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 these two values:
      #     targeted – Targeted processes are protected,
      #     mls – Multi Level Security protection.
      SELINUXTYPE=targeted

Step 9 >> 重启系统

最后补上成果图

123.png

223.png

原创文章,作者:黑白子,如若转载,请注明出处:http://www.178linux.com/13126

(1)
黑白子黑白子
上一篇 2016-03-21
下一篇 2016-03-22

相关推荐

  • shell脚本进阶

    一、流程控制 过程式编程语言:顺序执行、选择执行、循环执行 1.1 条件语句 1.1.1 if条件选择语句  选择执行: (注意: if 语句可嵌套) v  单分支:if  判断条件;then           条件为真的分支代…

    Linux干货 2016-11-27
  • Linux第一周心得

          第一次接触Linux,内心还是有点紧张,怕自己学不会、怕太难。不过,还是想挑战一下自己,所以来到了马哥学习Linux。      过来的第一天有点坎坷,不过还好有小琰姐的陪伴,一直和我们东西奔走,总算是解决了一大堆的麻烦,所以,感激……表白小琰姐!哈哈哈  撒花花  …

    Linux干货 2017-07-15
  • lamp+nfs搭建wordpress

    一、前言 lamp是大多上公司常用的架构,本文将针对分离式的lamp+nfs来搭建一个简单的wordpress网站。 二、架构图 三、基本实现过程 3.1:dns搭建 由于这这是一个实验,故使用yum搭建dns服务器 yum install -y bind 配置如下 dns主配置文件 dns辅助配置文件 zone文件 对所有服务…

    Linux干货 2015-10-16
  • 搜索引擎-网络爬虫

     通用搜索引擎的处理对象是互联网网页,目前网页数量以百亿计,搜索引擎的网络爬虫能够高效地将海量的网页数据传下载到本地,在本地 形成互联网网页的镜像备份。它是搜索引擎系统中很关键也很基础的构件。 1. 网络爬虫本质就是浏览器http请求。      浏览器和网络爬虫是两种不同的网络客户端,都以相同的方式来获取网…

    Linux干货 2015-11-18
  • 马哥教育网络班21期+第七周博客作业

    1、创建一个10G分区,并格式为ext4文件系统;    (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;    (2) 挂载至datamydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳 [root@ns1 ~]# m…

    Linux干货 2016-08-24
  • iptables之nat

    NAT网络地址转换SNAT:修改IP报文中的源IP地址 本地向互联网请求让本地网络中的主机可使用统一地址与外部通信,从而实现地址伪装请求:修改源IP,如果修改则由光梨园定义响应:修改目标IP,由nat自动根据会话表中追踪机制实现相应修改DNAT:修改目标地址转换 外网服务器向其他客户端请求请求:由外网主机发起,修改其目标地址,由管理员定义相应:修改源地址,但…

    2017-11-12

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

    写的不错。关于samba可以再从介绍些