如何在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

相关推荐

  • HA Cluster 之 vrrp (keepalived)

      HA Cluster 之 vrrp (keepalived) 0x00 前言 0x01 VRRP 协议 VRRP 简介 VRRP 工作原理 VRRP负载分担方式的特点 VRRP 中的一些术语 0x02 keepalived 功用: 0x03 keepalived 配置 HA Cluster 的配置前提: 配置文件组件部分: 配置文件解析: 附:…

    Linux干货 2017-05-16
  • 第一周课程练习

    马哥教育网络班22期+第一周课程练习 1、描述计算机的组成及其功能   CPU(运算器和控制器),存储器(内存和外存),输入/输出设备。     (1)运算器:对数据进行加工处理(包括算术运算与逻辑运算);     (2)控制器:负责从存储器取出一条指令,并指出下一条指…

    Linux干货 2016-08-15
  • MariaDB数据类型总结

        数据类型是数据的一种属性,它决定了数据的存储格式、有效范围及其它相应的限制。MariaDB的数据类型包括:字符型、整型、浮点值、日期时间型、布尔型及内建类型。 一、字符型     1、CHAR和VARCHAR类型     &nbsp…

    Linux干货 2015-06-30
  • 进程管理

    简述进程的相关理论与工具使用

    2017-09-09
  • 运维监控大数据的提取与分析

    本文内容整理来自【敏捷运维大讲堂】蒋君伟老师的线上直播分享。分别从以下3个维度来分享:1、云时代监控分析的窘境;2、使用标签标记监控数据的维度;3、监控数据应用场景。 云时代监控分析的窘境 在虚拟化与容器技术广泛应用的情况下,运维对象大规模地增长,监控平台每天存储的指标都以亿计,所以监控数据如今已经成了大数据。传统的监控工具在这种场景下,对于数据的提取分析,…

    系统运维 2017-01-09
  • 自动化运维跟安全配置

    安全相关工具rpm -qf /usr/bin/sshopenssh semanage port -a -t ssh_port_t -p tcp #PORTNUMBER/端口9527修改ssh的默认端口,ssh默认只能用22端口多台主机互联免口令1 ssh-keygen三台主机各自生成私钥公钥2 ssh-copy-id IP7三台主机各自复制公钥到同一台主机3…

    2018-02-06

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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