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

相关推荐

  • 条件选择if语句

    单分支的if语句 if 判断条件; then 条件为真的分支代码 fi       单分支if结构的执行流程:首先判断条件测试操作的结果,如果返回值为0表示条件成立,则执行then后面的命令序列,一直到遇见fi为止表示结束,继续执行其他脚本代码;如果返回不为0,则忽略then后面的命令序列,直接跳至fi行以后执行其他脚…

    Linux干货 2016-08-16
  • 马哥教育网络班20期+第5周课程练习

    1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; grep "^[[:space:]]\+.*" /boot/grub/grub.conf   2、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行; grep&nb…

    Linux干货 2016-07-12
  • CentOS 6开机启动流程实验篇

    CentOS 6开机启动流程实验篇 centos 系统的启动流程 grub 破坏Linux的核心文件再修复体验系统启动流程 CentOS 6开机启动的具体详情请参见理论篇! 了解了系统启动的基本流程,以下我们通过“破坏式实验”,即破坏系统启动过程中的一些关键环节,使系统无法启动,然后我们再通过修复这些文件使得系统正常重启,进而体验Linux系统的启动流程,这…

    Linux干货 2016-09-19
  • 逻辑卷的创建、维护和迁移

    逻辑卷管理器(LVM)介绍: 1、允许对卷进行方便操作的抽象层,包括重新设定文件系统的大小 2、允许在多个物理设备间重新组织文件系统 (1)将设备指定为物理卷 (2)用一个或者多个物理卷来创建一个卷组 (3)物理卷是用固定大小的物理区域(Physical Extent,PE)来 定义的 (4)在物理卷上创建的逻辑卷 是由物理区域(PE)组成 (5)可以在逻辑…

    Linux干货 2017-12-10
  • Linux如何进行分区和目录管理

    第七周作业   1、创建一个10G分区,并格式为ext4文件系统: 1、要求其block大小为2048,预留空间百分比为2,卷标为MYDATA,默认挂载属性包括acl; ~]# mke2fs -t ext4 -b 2048 -m 2 -L MYDATA /dev/sdb1 2、挂载至/data/mydata目录,要求挂载时禁止程序自动运行,县不更新…

    2017-09-18
  • 利用PXE技术批量安装linux系统

    技术背景 对与运维人员来说,如何安装操作系统想必并不陌生;但当我们面对大量需要安装系统的环境时,自动化安装系统就成了一项必备的技能;下面就让我们一起走进PXE这项批量自动化安装操作系统的技术吧。 PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,…

    2017-09-18

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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