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

相关推荐

  • python基础_1

    变量/常量 常量:一旦赋值,就不能对它从新复制。python不存在常量 字面常量:一个单独出现的量,未赋值给任何变量或者常量 变量:就是一个名字,在固执符号的左边,这个名字可以指复制符号右边的内容。 变量列子: i = 3 print(i)  注:python 是强类型语言,是动态类型语言。(强类型指类型之间不能相互计算/动态类型是指变量是可以赋值…

    Linux干货 2017-10-10
  • 马哥教育网络班22期+第二周课程练习

    week2作业: 1.linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 (1)touch 功能:创建文件 示例:  [root@director1 example]# touch file1 file2 [root@director1 example]# ll to…

    Linux干货 2016-08-22
  • 用户、组及其管理

    用户和组管理    Linux是一个多用户、多任务的操作系统。多用户、多任务就是可以在系统上建立多个用户,多个用户可以在同一时间内登录同一台主机的系统执行不同的任务,而互不影响。例如某台linux服务器上有4个用户,分别是root、www、ftp和mysql,在同一时间内root用户可能在管理维护系统,www用户可能在修改自己的程序和操作…

    Linux干货 2016-08-04
  • N26-第五周-孙逸

    1、 显示当前系统上root、fedora或user1用户的默认shell;命令:cat /etc/passwd | grep -E “^(root|fedroa|user1)” | cut -d: -f1,7 2、 找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello(…

    2017-03-10
  • 马哥教育网络班22期-第2周博客作业2

    2、bash的工作特性之命令状态返回值和命令展开所涉及的内容及其示例演示 bash的基础特性:命令的执行状态结果   命令执行的状态结果:   bash通过状态返回值来输出此结果:     成功:0     失败:1-255  &…

    Linux干货 2016-08-22
  • python快速入门之数据类型

        Python 是 90 年代初由 Guido Van Rossum 为了打发圣诞节而创建的语言。如今它已是当前最流行的程序语言之一.     Python的关键要素有以下几点:1.基本数据类型;2.对象引用;3.组合数据类型;4.逻辑操作符;5.控制流语句;6.算数操作符…

    Python干货 2015-12-10

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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