如何在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发展史 Linux的简单介绍 Linux操作系统诞生于1991 年,是一套免费使用和自由传播的类Unix操作系统。Linux存在着许多不同的Linux发行版本。严格意义上的Linux系统应该是GUN/Linux(kernel+Application)而Linux本身只表示Linux系统内核,但实际上人们已经习惯了用Linux称呼GUN/Linux系…

    Linux干货 2016-10-13
  • Linux之数组

      Linux之数组     数组介绍数组:存储多个元素的连续的内存空间,相当于多个变量的集合。 变量:存储单个元素的内存空间数组名和索引索引:编号从0开始,属于数值索引注意:索引可支持使用自定义的格式,而不仅是数值格式,即为关联索引,bash4.0版本之后开始支持。bash的数组支持稀疏格式(索引不连续)声明数组:de…

    Linux干货 2016-08-25
  • Linux用户和组管理

      用户和组管理类命令的使用方法 Liunx用户组管理命令: groupadd命令:添加组     命令用法:         groupadd [选项] group_name   &nbs…

    Linux干货 2016-11-25
  • N22-℡浮生.若夢 ╮第八周作业

    1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 集线器:集线器的主要功能是对接收到的信号进行再生整形放大,以扩大网络的传输距离 网桥:是早期的两端口二层网络设备,用来连接不同网段。网桥的两个端口分别有一条独立的交换信道,       不是共享一条背板总线,可隔离冲突域…

    Linux干货 2016-11-28
  • linux用户与组管理

    一、linux用户与组管理的基本介绍 1、任何一个用户想要使用Linux系统都要向管理员申请一个账号,对这些账号的管理即是对用户的管理,所谓组,就是多个账号的集合。用户和组管理可以提高用户的管理效率、工作效率以及系统的安全性,比如将同一个部门的成员放在一个组里并设置权限,这样可有效的对资源共享,同时可以避免其他部门的人恶意破坏。 2、用户和组的管理内容一般有…

    Linux干货 2016-08-02
  • 【N25第五周作业】find命令以及相关练习

    find: 实时查找工具,通过遍历指定起始路径下文件系统层级结构完成文件查找; 工作特性: 查找速度略慢; 精确查找; 实时查找; 用法: find [OPTIONS]  [查找起始路径]  [查找条件]  [处理动作] 查找起始路径:指定具体搜索目标起始路径;默认为当前目录; 查找条件:…

    Linux干货 2016-12-27

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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