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

相关推荐

  • 常见RAID介绍

    RAID简介 独立硬盘冗余阵列(RAID, Redundant Array of Independent Disks),旧称廉价磁盘冗余阵列(Redundant Array of Inexpensive Disks),简称磁盘阵列。主要目的是把多块硬盘组合起来提高数据处理能力、容错功能等 根据实现方式分为硬件和软件两种  硬件RAID:通过RAID…

    2016-04-12
  • 分析命令中含有e2fs

    分析命令中含有e2fs 目  录 1、mke2fs  2、tune2fs 3、dump2fs 4、e2fsck 这周学到了几条命令,超级纳闷为什么这些命令都带有e2fs ,看不懂。毕竟在我的认知中linux的命名大部分都是见名知义,例如history(查看历史命令),fdisk (分区),反观这些命令很长而且还是奇怪的…

    Linux干货 2017-08-20
  • Linux上功能强大的文本编辑工具—vim

    vim–Vi Improved是一款全屏文本编辑器 vi: Visual Interface,文本编辑器 可见,vim是vi的升级版,所以我们当然要学习vim! vim的功能强大,自然命令、用法也会种类繁多,想要用的得心应手自然是需要长期的实际操作的,正所谓工欲善其事必先利其器,我们要想能够在linux上从容应对繁多的文本编辑,无疑vim编辑器是…

    Linux干货 2016-08-12
  • Linux系统结构 详解

    Linux系统一般有4个主要部分: 内核、shell、文件系统和应用程序。内核、shell和文件系统一起形成了基本的操作系统结构,它们使得用户可以运行程序、管理文件并使用系统。部分层次结构如图1-1所示。  1. linux内核         内核是操作系统的核心,具有很多最基本功能,它负责管理系…

    Linux干货 2015-04-13
  • N25-第八周

    1、写一个脚本,使用ping命令探测172.16.250.1-172.16.250.254之间的所有主机的在线状态; 在线的主机使用绿色显示; 不在线的主使用红色显示; #!/bin/bash ipnet=172.16.250. trap ‘trap_action’ INT trap_action() { break return 1 } for ((i=1…

    Linux干货 2017-05-27
  • N26-博客作业-week14

    系统的INPUT和OUTPUT默认策略为DROP; 1、限制本地主机的web服务器在周一不允许访问;新请求的速率不能超过100个每秒;web服务器包含了admin字符串的页面不允许访问;web服务器仅允许响应报文离开本机; 配置系统INPUT和OUTPUT默认策略为DROP# iptables -P INPUT DROP# iptables -P OUTPU…

    Linux干货 2017-06-22

评论列表(1条)

  • stanley
    stanley 2016-03-22 10:39

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