首页 windows软件 手机软件 驱动下载 电脑教程 专题合集
当前位置: 首页 > 电脑教程 > Linux教程 > 实验:Samba服务器配置与管理

实验:Samba服务器配置与管理

时间:2014-04-02 13:00:01

小编:动力软件园

阅读:

 预备知识:      一、检测是否已经安装了samba客户端和服务器端      1、检查:      [root@localhost ~]# rpm -qa|grep samba      samba-3.0.23c-2 -----服务器端      samba-client-3.0.23c-2 -----客户端端      samba-common-3.0.23c-2 -----服务器端和客户端都需要      2、安装:      可以在安装盘的Server目录下找到rpm安装包(rhel6的软件包是在Packages目录下):      [root@localhost ~]# rpm -ivh /mnt/Server/samba-3.0.23c-2.i386.rpm      3、关闭防火墙和selinux:      二、samba的配置:(/etc/samba/smb.conf)      [root@localhost ~]# rpm –ql samba(如果没有找到,再找samba-common包)      [root@localhost ~]# rpm –ql samba-common      打开主配置文件,修改以文件实现共享:      [root@localhost ~]# vi /etc/samba/smb.conf      (主配置文件中的“#”表示只是一个注释,不能去掉“#”转化为语句,否则会报语法错误;“;”也表示注释,但该语句符合配置文件的语法,可以去掉“;”转化成配置文件的语句。samba的主要配置工作都是在主配置文件中实现;)      -----------------------GLOBAL Setting--------------------------      workgroup=WORKGROUP //和windows同在一个工作组      netbios name=SMB //设置samba服务器在windows的网上邻居中显示的名字      security = user      -----------------------SHARE definition---------------------------------      [11]      path = /home/student      comment = student      write list = @teachers      valid users = @teachers @students      :wq      3.重启samba服务,并测试。      应用案例一:      建立共享目录student,它的本机路径为”/home/student”,只有teachers组的用户可以读写该目录,students用户组只能读取。(注解:这个关键是不同组对同一个目录的权限设置,student这个目录属于students用户组,并设置他的OTHER 权限为7,我们通过这个OTHER权限来实现teachers组对student目录的访问,通过SMB的配置文件来限制用户访问)      一、 创建目录、用户、用户组      # groupadd students      # groupadd teachers      # useradd -g students stu01      # useradd -g teachers tch01      # smbpasswd -a stu01 //将linux系统账号加入samba中      New SMB password:      Retype new SMB password:      Added user stu01.      # smbpasswd -a tch01      New SMB password:      Retype new SMB password:      Added user tch01.      # mkdir /home/student      权限 主人 组 其他人 目录      Rwxr-xr-x root root teachers/students /home/student      1. Rwxrwxr-x root teachers /students /home/student      2. Rwxr-xrwx root students teachers /home/student      # chgrp students /home/student //改变目录/home/student的属组为students      Rwxr-xr-x root students(读) teachers(读写) /home/student      # chmod 757 /home/student // 设置OTHER 权限为7,teachers组通过OTHER 权限实现对student目录的访问      # chmod g+s /home/student //使目录/home/student永远属于students组      二、然后将samba服务器加入windows工作组:      #vi /etc/samba/smb.conf      -----------------------GLOBAL Setting----------------------------------------------------------      workgroup=WORKGROUP //和windows同在一个工作组      netbios name=SMB //设置samba服务器在windows的网上邻居中显示的名字      security = user      -----------------------------SHARE definition---------------------------------------------------------------      [11]      path = /home/student      comment = student      write list = @teachers      valid users = @teachers @students      :wq      [root@localhost ~]# service smb restart      关闭 SMB 服务: [确定]      关闭 NMB 服务: [确定]      启动 SMB 服务: [确定]      启动 NMB 服务: [确定]      三、测试:      在windows中打开网上邻居:刷新,即可看到SMB服务器      如果看不到,在地址栏:服务器IP      输入stu01,密码stu01,对student文件夹只有读的权限,没有写的权限;      输入tch01,密码tch01,对student文件夹有读写的权限;

火爆手游