1.查看防护墙

[root@zhang~ ]# /etc/init.d/iptables status   
iptables:Firewall is not running.

如果没有关闭的话将他规则清空并关闭

iptables–F      
iptables–L       
/etc/init.d/iptablessave    
/etc/ini.d/iptablesstop   
chkconfigiptables off

关闭后再次查看状态

 

2.查看selinux

[root@zhang~]# sestatus         
SELinuxstatus:                 disabled

 

如果没有关闭的话手动将他关闭,并重新启动服务器

 

3.查看软件安装状态

[root@zhang~]# rpm -qa | grep samba  
samba-winbind-3.6.23-44.el6_9.x86_64  
samba-client-3.6.23-44.el6_9.x86_64   
samba4-libs-4.2.10-6.el6_7.x86_64  
samba-common-3.6.23-44.el6_9.x86_64  
samba-winbind-clients-3.6.23-44.el6_9.x86_64


4.查看需要装的安装包

[root@zhang~]# yum grouplist | grep file                      
Repositorybase is listed more than once in the configuration       
Repositoryupdates is listed more than once in the configuration      
Repositoryextras is listed more than once in the configuration       
Repositorycentosplus is listed more than once in the configuration   
Repositorycontrib is listed more than once in the configuration      
Loadingmirror speeds from cached hostfile                       
CIFS file server  
   NFSfile server      
   Network file system client       
 
[root@zhang~]# yum groupinfo 'CIFS file server'
Loadedplugins: fastestmirror, refresh-packagekit, security
Settingup Group Process
Repositorybase is listed more than once in the configuration
Repositoryupdates is listed more than once in the configuration
Repositoryextras is listed more than once in the configuration
Repositorycentosplus is listed more than once in the configuration
Repositorycontrib is listed more than once in the configuration
Loadingmirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.sohu.com

Group:CIFS file server
 Description: Share files between Linux andMicrosoft Windows systems.
 Mandatory Packages:
 samba
 Optional Packages:
   tdb-tools

安装需要的包:

[root@zhang~]# yum groupinstall 'CIFS file server' –y

 

再次查看已经安装的samba的安装包

[root@zhang~]# rpm -qa | grep samba

samba-winbind-3.6.23-44.el6_9.x86_64
samba-client-3.6.23-44.el6_9.x86_64
samba4-libs-4.2.10-6.el6_7.x86_64
samba-common-3.6.23-44.el6_9.x86_64
samba-winbind-clients-3.6.23-44.el6_9.x86_64
samba-3.6.23-44.el6_9.x86_64

二、编写配置文件

1.配置文件所在路径是

[root@zhangsamba]# ls
lmhosts  smb.conf   smbusers
[root@zhangsamba]# pwd
/etc/samba

 

2.备份配置文件

[root@zhangsamba]#cp smb.conf smb.conf.bak 
[root@zhangsamba]# ls
lmhosts  smb.conf smb.conf.bak  smbusers

 

3.将配置追加到配置文件末尾

[zhang]
        path=/shared/zhang         --指定共享文件的路径       --   
        writable = yes              --用来指定该共享路径是否可写  
        create mask = 1444                           
        directory mask = 1555       --create和directory这两个权限可以控制文件可以下载上传,但是无法删除和修改


附录中有完整的smb.conf文件的配置信息

 

4.创建需要的文件

[root@zhangsamba]#mkdir /shared/zhang/


5.修改文件的权限

[root@zhang samba]# chmod a+w /shared -R

6.启动服务

[root@zhangsamba]# service smb start
[root@zhangsamba]# service nmb start
[root@zhangsamba]# chkconfig smb on
[root@zhangsamba]# chkconfig nmb on

 

7.查看端口

[root@zhangsamba]# netstat -lntup | grep mbd

 

8.将系统用户装换为samba的用户

[root@zhangsamba]#useradd samba   --这个用户随便名称都可以
[root@zhangsamba]# smbpasswd-a samba           --“-a”后面跟的用户是新创建的用户
NewSMB password: admin  
Retypenew SMB password:admin

上面输入的密码是windows登录共享文件服务器的时候需要的密码

 

三、windows访问共享文件服务器

这里的ip是192.168.1.118

这里的账号密码就是新创建的用户和smb的密码

我这里是用户:samba 密码是:admin

 

这样就可以进入了

 

可以进行上传文件和读取文件的内容,但是无法进行修改保存,更无法删除

 

测试:

创建了一个txt文件,内容如下:

将其上传到共享文件中

 

打开是没有问题的

                       

修改后:

但是修改后保存会提示:

这是修改后覆盖源文件的报错

这是想要重新命名的报错

会创建相应的文件,但是文件是没有任何内容的空文件

想要删除的话:

 

需要联系管理员从文件服务器中删除

 

 

 

 

 

附录1:

sam的配置文件smb.conf的全部内容

[root@vm123 samba]# more smb.conf
 
[global]
       workgroup = LQ1507
       server string = AYYK Server Version %v
       log file = /var/log/samba/log.%m
       max log size = 50
       #nt pipe support = no
       security = share
       load printers = yes
       cups options = raw
       netbios name = LQ1507FilesServer
       hosts allow = 127. 192.168.1. 192.168.6. 10.10.1. 10.0.0.
[homes]
       comment = Home Directories
       browseable = no
       writable = no
[share]
       path = /shared/share
       public = yes
       guest ok = yes
       #browseable = no
       #writable = yes
       read only = no
[tools]
       path = /shared/tools
       public = yes
       guest ok = yes
       writable = yes
       read only = no
                  guset ok = yes
[开发]
                   path=/shared/研发中心
                  writable = yes
                  create mask = 1444
                 directory mask = 1555
                  guest ok = yes

 

 

 

附录2:

#1.全局部分参数设置:
[global]
       #与主机名相关的设置
       workgroup = zkhouse  <==工作组名称
       netbios name = zkserver   <==主机名称,跟hostname不是一个概念,在同一个组中,netbios name必须唯一
       serverstring = this is a test samba server <==说明性文字,内容无关紧要
       #与登录文件有关的设置
       log file = /var/log/samba/log.%m  <==日志文件的存储文件名,%m代表的是client端Internet主机名,就是hostname
       max log size = 50      <==日志文件最大的大小为50Kb
       #与密码相关的设置
       security= share       <==表示不需要密码,可设置的值为share、user和server
       passdb backend = tdbsam
       #打印机加载方式
       load printer = no <==不加载打印机
-----------------------------------------------------------
#2.共享资源设置方面:将旧的注释掉,加入新的
#先取消[homes]、[printers]的项目,添加[temp]项目如下
[temp]              <==共享资源名称
       comment = Temporary file space <==简单的解释,内容无关紧要
       path = /tmp     <==实际的共享目录
       writable = yes    <==设置为可写入
       browseable = yes   <==可以被所有用户浏览到资源名称,
       guest ok= yes    <==可以让用户随意登录