如何在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基础知识之压缩、解压、归档工具

    压缩、解压、归档工具     压缩格式:gz,bz2,xz,zip,Z 压缩算法不同,压缩比也会不同     1.compress/uncompress (.Z) compress [-dfvcVr] [-b maxbits] [file …] -d: 解压缩,相当于 -c: 结果输出至标准输出, 不删除原…

    Linux干货 2016-08-19
  • 计算机基础知识

    计算机系统 计算机系统组成的两大部分 硬件系统     主机         中央处理器CPU{运算器,控制器}         内存储器{ROM,RAM} &…

    Linux干货 2016-08-04
  • 基础指令使用篇 Linux版

    回显,回声 echo echo hello > /dve/pts/1 打开图形界面 init 5   关闭图形界面 init 3 ctrl+alt+F1-6字符,F7图形界面 chvt 改变虚拟终端 chvt +数字 startx  图形的软件打开 poweroff centOS 6.8与7.2都正常关闭断电 hostname 显示…

    系统运维 2016-08-04
  • Linux之任务计划 crontab

    Linux之任务计划    用过windows的同学应该都知道在控制面板中有一个“任务计划”选项,我们可以通过向导设置让计算机在某个时间点或者开机时运行某个脚本或者批处理等等,方便我们的日常管理监视工作;同样在Linux系统中,如果我们想在开机时就运行某个操作,可以直接将命令写入/etc/rc.local中,该操作就会在机器开机时运行;如…

    Linux干货 2015-05-18
  • 第二周学习总结

    写在最前 通过上一周对计算机系统、Linux发展的学习,我们认识到了Linux是一个一切皆文件的内核系统。那么怎样去操作系统上的各文件来达到你想要的目的呢?今天的总结就是帮助我们更快的达成目标。 文件管理类命令的分类 对于这类命令主要分为两类: 操作类:touch、cp、mv 查看类:cat、tac、head、tail、less、more touch 功能描…

    2017-12-16
  • 与正则表达式的第一次亲密接触

    Linux文本处理三剑客 grep:文本过滤(模式:psttern)工具 grep,egrep,fgrep (不支持正则表达式搜索) sed:stream editor,文本编辑工具 awk:Linux上的实现gawk,文本报告生成器 下面就先谈一谈:grep及正则表达式;egrep及扩展的正则表达式 grep grep:Goobal search REgu…

    Linux干货 2017-04-06

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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