如何在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 20:48
下一篇 2016-03-22 10:41

相关推荐

  • Linux系统上获取命令的帮助信息方法

    当我们在操作linux时忘记相关命令的用法时,可以使用man 命令或者命令 -h来查询该命令的用法; man文档共有9个章节 1:所有用户可以操作的指令或可执行文件 2:系统核心调用的函数与工具 3:子调用,常用的函数与函数库 4:设备,硬件文件说明,通常是/dev/的文件 5:文件格式,配置文件或者是某些档案的格式 6:游戏相关 7:杂项,例如linux文…

    Linux干货 2018-03-04
  • LAMP架构实验1

    LAMP架构实验 — 基础架构搭建 实验实验拓扑图与目的 实验过程 总结与问题 实验实验拓扑图与目的 1. 实验主框架LAMP采用编译安装。 2. 分离HTTPD,PHP,MARIADB。 3. 两台服务器能够各自被访问且内容相同。 实验过程 程序包准备: apr-1.5.2.tar.gz          …

    Linux干货 2016-05-10
  • http和apache服务器

    超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议。所有的WWW文件都必须遵守这个标准。设计HTTP最初的目的是为了提供一种发布和接收HTML页面的方法。 http/1.1 :1997年1月 引入了持久连接(persistent connection) , tcp连接默认不关闭,可以被多个请…

    2017-12-05
  • 第八周作业

    1. 写一个脚本,使用ping命令探测172.16.250.1-172.16.250.254之间的所有主机的在线状态;     在线的主机使用绿色显示;     不在线的主机使用红色显示; #!/bin/bash # for i in {1..254};do         pi…

    Linux干货 2017-02-24
  • 逻辑卷LVM的实现

    LVM(Logical Volume Manager,逻辑卷管理)可以实现把多个实体硬盘分区整合在一起,当作一个硬盘来重新操作处理。最重要的是LVM不像传统分区一旦确定分区大小就不能再调整,它允许我们弹性的调整分区及文件系统容量! 通过几道练习题来说明LVM的实现 1、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小为16MB,…

    2017-06-25
  • 一起学DNS系列(十四)DNS查询工具之DIG的使用(2)

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://jeffyyko.blog.51cto.com/28563/240243    上节谈到了利用DIG的+trace参数追踪域名解析的过程,其实除此之外,DIG还有一些其他的参数,这节会涉及到这…

    2015-03-17

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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