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

相关推荐

  • 软件包管理

    软件运行与编译过程:程序源代码——预处理——-编译——-汇编——-链接 静态编译:.a 动态编译:.so 二进制程序的组成:二进制文件、库文件、配置文件、帮助文件。 包的命名:1、源代码:name -VERSION.tar.gz或bz2或xz   &nb…

    Linux干货 2017-04-23
  • puppet代码分析

    这篇博客的目的是通过分析Forge上的Puppet模块来加深一些概念的理解,同时了解一些常用用法。 今天的例子是jfryman-nginx模块,它是原puppetlabs-nginx模块的升级版本,依赖3个Puppet公共模块:puppetlabs-apt,puppetlabs-stdlib和puppetlabs-concat。安装非常方便,puppet m…

    2017-03-18
  • 路由配置

      RA和RB为linux系统,此处虚拟成为路由器,在每一台路由器的接口上设置好ip之后开始配置路由表 ip地址配置如下: RA:eth1:192.168.100.1/24    eth0:10.1.0.1/8       主机A:10.1.0.25/8 RB: eth1:192.168.100.2…

    Linux干货 2016-09-07
  • linux中常用文本处理工具

       在linux文件系统中经常会使用到文本处理工具,这里简单介绍几种文本处理工具: 抽取文本的工具 文件内容:less和cat 文件截取:head和tail 按列抽取:cut 按关键字抽取:grep , egrep 文件查看命令:cat, tac,rev,more,less   cat命令是用户经常使用的用来查看文本…

    Linux干货 2016-08-07
  • CIDR,子网掩码以及划分子网超网

    对于中小企业,假如有两千台机器,给他分个B类地址,6万多个,太浪费了,分个C类地址,一个C类地址254个,又不够,又得多申请几个,所以A,B,C类IP地址划分太过僵硬,很不灵活,因此又提出无类域间路(CIDR)由划分IP地址的方法。 无类域间路由(CIDR) 传统划分IP地址的方法都是8位划分的,要不就是前8位网络ID,后24位主机ID;或前16位网络ID,…

    2017-09-16
  • Lvm基本应用,扩展及缩减实现

    什么是LVM LVM是Logical Volume Manager的简写。其是Linux环境下对磁盘分区进行管理的一种机制。LVM由Heinz Mauelshagen在Linux 2.4内核上实现。其主要作用是在不损坏磁盘数据的情况下对磁盘空间进行增加,缩减。LVM的做法是将几块物理硬盘通过软件的方式组合成一块空间相对大的Volume Group,简称VG,…

    Linux干货 2016-09-08

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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