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

相关推荐

  • 网络N23期第一周(计算机的组成及功能及Linux的发行版等)

    一. 描述计算机的组成及功能 计算机由五大硬件组成:” 运算器 + 控制器 + 储存器 + 输入设备 + 输出设备” 。 运算器(Datapath):运算器的功能是对数据进行各种算术运算和逻辑运算,即对数据进行加工处理。 控制器(Control):是整个计算机的中枢神经,其功能是对程序规定的控制信息进行解释,根据其要求进行控制,调度程序、数据、地址,协调计算…

    Linux干货 2016-09-22
  • bash的基本特性之globbing,IO重定向及管道

    bash的基本特性之globbing,IO重定向及管道 giobbing:文件名通配 在bash的操作环境中有一个分厂有用的功能那就是gilobbing:文件名通配,这样我们在处理数据的时候就更方便了。下面我们来罗列一些常用的通配符。(注:globbing是做整体的文件名匹配而非部分) 匹配模式:元字符 *:表示匹配任意长度的任意字符  &nbsp…

    Linux干货 2016-12-19
  • 马哥Linux第三周作业

    正则表达式 用户和组管理

    Linux干货 2017-12-31
  • 马哥教育网络班21期+第1周课程练习

    1.描述计算机的组成及其功能。   计算机主要由运算器,控制器,存储器,输入设备,输出设备组成   运算器用来做计算,用来做二进制运算(加法运算)和逻辑运算   控制器用来控制计算机各部件之间的协调,例如运算器想做运算从哪里读入加数和被加数,寄存在哪里   存储器分为内存储器和外存储器,用来存放数据 内存储器用于存放计…

    Linux干货 2016-07-12
  • Linux中软链接和硬链接的区别

    Linux中软链接和硬链接的区别 链接文件:   Linux中包括两种链接:硬链接(Hard Link)和软链接(Soft Link),软链接又称为符号链接(Symbolic link)。 Inode 文件除了纯数据本身之外,还必须包含有对这些纯数据的管理信息 文件名; 访问权限; 文件的属主以; 该文件的数据所对应的磁盘数据块; 文件的时间戳; …

    Linux干货 2016-10-20
  • 文件查找locate和find

    locate 查询系统上预建的文件索引数据库 /var/lib/mlocate/mlocate.db 依赖于事先构建的索引 索引的构建是在系统较为空闲时自动进行(周期性任务),管理员手动更新数据库(updatedb) 索引构建过程需要遍历整个根文件系统,极消耗资源 工作特点: •查找速度快 •模糊查找 •非实时查找 •搜索的是文件的全路径,不仅仅是文件名 •…

    2017-08-11

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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