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

相关推荐

  • 一位老it工程师的忠告,新手进来学习,老手进来体会,收获很大。

    诸位,咱当电子工程师也是十余年了,不算有出息,环顾四面,也没有看见几个有出息的!回顾工程师生涯,感慨万千,愿意讲几句掏心窝子的话,也算给咱们师弟师妹们提个醒,希望他们比咱们强! [1]好好规划自己的路,不要跟着感觉走!根据个人的理想决策安排,绝大部分人并不指望成为什么院士或教授,而是希望活得滋润一些,爽一些。那么,就需要慎重安排自己的轨迹。从哪个行业入手,逐…

    Linux干货 2015-02-26
  • LVM基本应用,扩展以及缩减的实现

    这是一篇马哥课堂博客作业,这次换个表现方式写,前面先写总体的操作过程,后面显示详情 其实马哥视频讲的非常详尽,听起来特别容易理解,只是让我要写出来那得费九牛二虎之力,估计还得照着视频写。如下仅是看过视频之后的一个操作过程,比较粗糙,仅仅是作业。。。 LVM:logical volume manager version2 逻辑卷管理系统 PV:physical…

    Linux干货 2016-06-28
  • 用户及权限管理

     今天是学习马哥教育第四天,也是第一个博客作业,写一篇关于用户及权限管理的简介型的博客文章,作文水品有限,所以写出来有可能有病句或者意境有问题,请大家多多包涵。  首先,用户及权限管理,需要从2方面入手来说,首先来说用户管理。  何谓用户,这是马哥一上来就提到的问题,我简单的理解,用户其实就是一个人机交互的接口,人机交互的接口是…

    Linux干货 2016-09-15
  • 马哥教育网络班22期第一周课程练习1-未闻花名

    一、cpu架构 计算机体系结构: 运算器、控制器(cpu还包含寄存器)、存储器(内存)、输入设备(键盘、硬盘等)、输出设备(显示器、硬盘等) cpu组成: 核心部件:运算器(加法器)、控制器()、寄存器(由于数据总线复用,为cpu保存现场,过程数据记录)。 辅助部件:一、二、三级缓存:弥合CPU和内存速率不匹配。频率控制器? 地址总线:内存寻址。 数据总线:…

    Linux干货 2016-08-15
  • 内核编译安装 (用NTFS模块)

    内核编译安装 (用NTFS模块) 1 rz 下载的 的内核最新文件 在这 https://www.kernel.org/ 2 tar xvf linux-4.12.10.tar.xz 解压文件 内核文件一般都放在 /usr/src/ 3 cd linux-4.12.10/ 4 [root@god linux-4.12.10]#cp /boot/config-…

    2017-09-04
  • 通过Nginx来安装一个discuz,软件并不是编译安装的

    这次由于时间有限,所以我就没有用编译安装来启动LMP,只有Nginx 是编译安装的 因为是在centos7上面安装的Nginx所以我们这里由于能力有限,暂时不能将其加入开机启动,日后我会进行改进,将其加入开机启动。这里我们给出Nginxd的编译选项及环境   yum groupinstall "Development&…

    Linux干货 2016-10-25

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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