学习linux从实践做起。

实验环境:vmware,cenots 6,xshell

注意:使用vmware 时,网络连接设置成桥接,和宿主机位于同一个网段。

实验需求:模拟实际公司文件服务器。 新建SHARE 文件夹,权限所有人公开

新建IT 文件夹,只对IT部门员工开放

新建DE文件夹,对于DE部门员工开放

实验步骤:

1:由于selinux设置不懂,和iptables 只了解皮毛,为了不必要的麻烦:

关闭selinux :

 [root@localhost ~]# vi /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

关闭iptables:

 [root@localhost ~]# service iptables stop;chkconfig iptables off;chkconfig --list | grep iptables
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables :off :off :off :off :off :off :off

2:reboot,查看并且确保生效

 [root@localhost ~]# reboot
之后,继续查看
[root@localhost ~]# chkconfig --list | grep iptables
iptables :off :off :off :off :off :off :off

3:新建SHARE,IT,DE文件夹并设置权限

 [root@localhost ~]# mkdir -m  /home/SHARE /home/IT /home/DE
[root@localhost ~]# ls -l /home/
total
drwxrwx---. root root Dec : DE
drwxrwx---. root root Dec : IT
drwxrwx---. root root Dec : SHARE

4:新建用户组SHARE,IT,DE,新建IT1,IT2用户,新建DE1,DE2用户(IT1,IT2,DE1,DE2属于SHARE组,IT1,IT2属于IT组,DE1,DE2属于IT组)

 [root@localhost ~]#  groupadd SHARE;groupadd IT;groupadd DE
[root@localhost ~]# cat /etc/group
...
SHARE:x::
IT:x::
DE:x::
[root@localhost ~]# useradd IT1;usermod -s /sbin/nologin IT1 ;gpasswd -a IT1 IT; useradd IT2;usermod-s /sbin/nologin IT2 ;gpasswd -a IT2 IT; useradd DE1;usermod  -s /sbin/nologin DE1 ;gpasswd -a DE1 DE;useradd DE2 ;usermod -s /sbin/nologin DE2 ;gpasswd -a DE2 DE; gpasswd -a IT1 SHARE ;gpasswd -a IT2 SHARE;gpasswd -a DE1 SHARE; gpasswd -a DE2 SHARE

[root@localhost ~]# cat /etc/group
...
public:x::IT1,IT2,DE1,DE2
IT:x::IT1,IT2
DE:x::DE1,DE2
IT1:x::
IT2:x::
DE1:x::
DE2:x::

5:安装samba

 [root@localhost ~]# yum -y install samba samba-client samba-swat
 [root@localhost ~]# rpm -qa | grep samba
samba-winbind-clients-3.6.-.el6_7.x86_64
samba-swat-3.6.-.el6_7.x86_64
samba-client-3.6.-.el6_7.x86_64
samba-3.6.-.el6_7.x86_64
samba-winbind-3.6.-.el6_7.x86_64
samba-common-3.6.-.el6_7.x86_64

6:备份smb.conf

 [root@localhost ~]# cp  /etc/samba/smb.conf /etc/samba/smb.conf.bk

7:将用户账户添加到samba账户

 [root@localhost ~]# smbpasswd -a IT1
New SMB password:
Retype new SMB password:
Added user IT1.
[root@localhost ~]# smbpasswd -a IT2
New SMB password:
Retype new SMB password:
Added user IT2.
[root@localhost ~]# smbpasswd -a DE1
New SMB password:
Retype new SMB password:
Added user DE1.
[root@localhost ~]# smbpasswd -a DE2
New SMB password:
Retype new SMB password:
Added user DE2.

查看samba服务中,注册了哪些用户

 [root@localhost ~]# pdbedit -L
IT1::
DE1::
IT2::
DE2::

8:修改smb.conf配置文件

   [SHARE]
comment = share
path = /home/SHARE
valid users = @SHARE
read only = No
create mask =
directory mask = [IT]
comment = IT
path = /home/IT
valid users = @IT
read only = No
create mask = [DE]
comment = DE
path = /home/DE
valid users = @DE
read only = No
create mask =
directory mask =

9:重启samba服务:

 [root@supker ~]# service smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
[root@supker ~]# service nmb restart
Shutting down NMB services: [ OK ]
Starting NMB services: [ OK ]

《此处,请允许我感慨一声,真是日了狗了,测试半天,都是没有权限新建文件,然而reboot一下,就可以了!》

10:测试结果展示:

提示:断开共享盘连接的windows CMD命令:net use  * /del /y

Centos 6 之samba 搭建的更多相关文章

  1. Centos 基础开发环境搭建之Maven私服nexus

    hmaster 安装nexus及启动方式 /usr/local/nexus-2.6.3-01/bin ./nexus status Centos 基础开发环境搭建之Maven私服nexus . 软件  ...

  2. 如何在Fedora或CentOS上使用Samba共享

    如今,无论在家里或者是办公场所,不同的电脑之间共享文件夹已不是什么新鲜事了.在这种趋势下,现代操作系统通过网络文件系统的方式使得电脑间数据的交换变得简单而透明.如果您工作的环境中既有微软的Window ...

  3. CentOS 5.5 Samba服务器安装总结

    centos 5.5 samba服务器安装总结先来介绍一下基本的内容windows和linux共享主要利用samba服务器,所谓SMB就是指server message block 的缩写,它是Lin ...

  4. CentOS 6.2下搭建Web服务器

    1Centos 6.2下搭建web服务器 如今,Linux在Web应用越来越广,许多企业都采用Linux来搭建Web服务器,这样即节省了购买正版软件的费用,而且还能够提高服务器的安全性. 之前我们介绍 ...

  5. 在CentOS上配置SAMBA共享目录(转载)

    在CentOS上配置SAMBA共享目录 From: https://blog.csdn.net/qiumei1101381170/article/details/53265341 2016年11月21 ...

  6. CentOS 6.3下搭建Web服务器

    准备前的工作: 1.修改selinux配置文件(/etc/sysconfig/selinux) 关闭防火墙 (1)把SELINUX=enforcing注释掉 (2)并添加SELINUX=disable ...

  7. CentOS 7设置Samba共享目录

    1. 安装Samba服务 yum -y install samba # 查看yum源中Samba版本 yum list | grep samba # 查看samba的安装情况 rpm -qa | gr ...

  8. 手把手教你在CentOS 7.4下搭建Zabbix监控(转)

    Linux系统版本:CentOS 7.4 1.安装前需要先关闭selinux和firewall. 1.1 [root@zabbix ~]# vi /etc/selinux/config 将SELINU ...

  9. centos set up samba

    原文中文链接:https://wiki.centos.org/zh/HowTos/SetUpSamba 原文英文链接:https://wiki.centos.org/HowTos/SetUpSamba ...

随机推荐

  1. input、button、文字的对齐水平对齐

    input.button.文字的对齐~! 1.input文本框下移的方法:padding-top ,可以解决文本框向下移. 2.input文本框和button对齐可以给他们外面加table (例如,谷 ...

  2. 修改crontab默认的编辑器

    1.crontab默认的编辑器为nano; 2.修改为vi或其他编辑器 export EDITOR="/usr/bin/vim" ; crontab -e

  3. samba 配置

    sudo apt-get install samba sudo apt-get install kdenetwork-filesharing vi /etc/samba/smb.conf [Share ...

  4. Sublime Text 3开启自动换行

    在Submine Text 3中要开启自动换行功能只需要两个步骤: 1.找到查看(View) 2.点击弹出菜单中的自动换行即可 但是如果是在2中的话就相对麻烦少少,现在也说下其开启自动换行功能的步骤: ...

  5. HyperV上的Linux虚拟机启动报panic_early_exception错误

    在Windows Server 2012服务器上的HyperV安装的Oracle Linux 6.4版本,在增加内存容量后(有16G升至30G),操作系统无法启动.黑屏并报"PANIC: e ...

  6. iOS下UITableView的单元格重用逻辑

    终于有时间继续UITableView的接口调用顺序这篇文章了,之前测试过,模拟器都是按照height,cellForRow这样的顺序调用接口的,iOS8以前一直是这样,但是到了iOS8,这个顺序倒过来 ...

  7. nvcc fatal : Cannot find compiler 'cl.exe' in PATH解决方法

    我在测试安装的deep learning工具theano.按照官网Baby Steps - Algebra一步步输入. >>> import theano.tensor as T & ...

  8. linux的七种文件类型

    d 目录 - 普通文件 l 符号链接 s 套接字文件 b 块设备文件 二进制文件 c 字符设备文件 p 命名管道文件

  9. ucos3的配置文件

    1,配置文件,用于系统的裁剪 均有详细的注释 为组件的开关 ​ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ...

  10. PHP代码标识

    1. Echo语句(打印) <?php echo "想学习PHP么"; ?> 2. 计算表达式 <?php echo 12*3; ?> 3. 字符串 < ...