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

相关推荐

  • 探索处理文本工具“sed”的相关奥妙

    一:sed工具 1,set的介绍:sed是一种流编辑器,它一次处理一行内容。处理时,把当前 处理的行存储在临时缓冲区中,称为“模式空间”(patternspace),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。然后读入下行,执行下一个循环。如果没有使诸如‘D’的特殊命令,那会在两个循环之间清空模式空间,但不会清空保留空间。这样不断…

    2017-08-26
  • linux文件基本权限讲解

    linux文件基本权限讲解 Linux系统是一种典型的多用户系统,不同的用户处于不同的地位,拥有不同的权限。为了保护系统的安全性,Linux系统对不同的用户访问同一文件(包括目录文件)的权限做了不同的规定。 Linux系统中一切都是文件,文件和目录的所属与权限——来分别规定所有者、所有组、其余人的读,写,执行权限。 在Linux中我们可以使用ll或者ls –…

    Linux干货 2016-09-05
  • N21-北京-兔锅-马哥教育网络班21期+第二周课程练习

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 A.wc命令: 功能:统计指定文件中的字节数、字数、行数,并将统计结果显示输出 语法:wc [选项]文件… 参数: -c:统计字节数。 -l:统计行数。 -m:统计字符数。这个标志不能与 -c 标志一起使用。 -w:统计字数。一个字被定义为…

    Linux干货 2016-07-07
  • 一切皆文件——Linux基本命令(1)

    1.一切皆文件 在dev下有很多硬件的文件 sr0是光驱 console是终端,也划为一个文件   2.查看终端   3.两个终端发信 首先右键选择Clone Session,新客隆了一个centos6 分别使用tty命令查看终端名。 分别为0和1 通过命令:echo “想发送的信息“ > 终端名 即可发送 在0中输入命令: 在1中…

    Linux干货 2017-07-13
  • python面向对象魔术方法

    python面向对象魔术方法

    Linux干货 2017-11-20
  • 千里眼–用NFS和Samba实现共享网页文件

     目的:使用网络文件系实现LAMP的分步式资源共享 配置过程– 搭建nfs服务器:(centos 6.8) 安装yum install mysql-server nfs-utils httpd #这里安装httpd是为了方便后面共享文件的属主属组定义 启动nfs服务 #service nfs start  mkdir /dat…

    2017-04-30

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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