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

相关推荐

  • ​第五周作业

    1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; [root@localhost ~]# grep  -E "^[[:space:]]+" /boot/grub/grub.conf  root (hd0,0) kernel&nbs…

    Linux干货 2017-02-05
  • 管理用户组的命令

    用户账户 管理用户的命令及配置文件, Useradd,usermod,userdel,newusers,chpasswd,passwd,chage,chfn,chsh,id,su,finger Useradd:创建用户,         Useradd 选项 参数  &…

    Linux干货 2016-10-23
  • 文本处理工具

    文本查看工具 less [les]  查看文件 功能比MORE更强大      -N  显示行号      查看时使用的命令      / OR ? 搜索的内容    搜索关键字 &nbsp…

    Linux干货 2017-04-13
  • Linux系统上获取命令的帮助信息方法

    当我们在操作linux时忘记相关命令的用法时,可以使用man 命令或者命令 -h来查询该命令的用法; man文档共有9个章节 1:所有用户可以操作的指令或可执行文件 2:系统核心调用的函数与工具 3:子调用,常用的函数与函数库 4:设备,硬件文件说明,通常是/dev/的文件 5:文件格式,配置文件或者是某些档案的格式 6:游戏相关 7:杂项,例如linux文…

    Linux干货 2018-03-04
  • 马哥教育网络第21期-第八周课程练习

    1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。   网桥从一个局域网接收MAC帧,拆封、校对、校验之后,按另一个局域网的格式重新组装,发往它的物理层。由于网桥是链路层设备,因此不处理数据链路层以上层次协议所加的报头。   集线器的主要功能是对接收到的信号进行再生整形放大,以扩大网络的传输距离,同时把所有节点…

    Linux干货 2016-10-24
  • 几个正则表达式和find查找语句事例

    显示当前系统上root、fedora、或user1用户的默认shell; ~]# grep -E "^(root|bin|hadop)" /etc/passwd | cut -d: -f7 找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如: hello(); ~]#grep -E -o &qu…

    Linux干货 2016-10-30

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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