编程随想录
CSDN拆迁户 @2014-04-07

导航

 


一、安装samba服务
     yum -y install samba


二、配置smaba服务器
编辑/etc/samba/smb.conf。
        security = user
;       security = share
         passdb backend = tdbsam

找到 Share Definitions, 注释掉所有的共享定义, 添加一个:
[Fedora]
         comment = Fedora Samba
         path = /home/chen
         public = yes
         browseable = yes
         writable = yes
         write list = chen,root
         create mask = 0777
         directory mask = 0777

[root@localhost ~]# vi /etc/Samba/smb.conf ← 编辑 Fedora Samba 的配置文件
workgroup = WORKGROUP //设置工作组
server string = %U's Samba %v //描述信息%U代表当前登陆用户
netbios name = fedora //netbios名字,fedora9 默认没有启用
log file = /var/log/Samba/log.%m //日志文件保存路径%m你的windows主机名
max log size = 50 //日志最大容量
security = user //安全级别,user需要用户名和密码,share级别则不要
[Fedora Samba] //建立一个共享名为Fedora Samba的共享
comment = Samba//描述信息
path = /home/bsc/samba//共享路径
public = no //是否允许guest用户访问(相当于guest ok = yes/no), 改为yes
writable = yes //是否可写
write list = bsc //可以写入的用户列表(@代表用户组)

三、建立共享目录
[root@localhost ~]# mkdir /home/bsc/samba ← 建立共享文件专用目录
[root@localhost ~]# chown -R nobody /home/bsc/samba ← 设置专用目录归属为 nobody
[root@localhost ~]# chmod 777 /home/bsc/samba/ ← 将专用目录属性设置为 777
[root@localhost ~]# smbpasswd -a bsc ← 将系统用户 bsc(此用户必须未已存在的,如果不存在,useradd name添加吧)加入到 Fedora Samba 用户数据库
New SMB password:  ← 输入该用户用于登录 Samba 的密码
Retype new SMB password:  ← 再次确认输入该密码
[root@localhost ~]#


第四步 启动 samba服务

首先要把防火墙打开
[root@localhost ~]# vi /etc/sysconfig/iptables  ← 编辑 iptables 配置文件
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT  ← 找到此行,在下面添加如下行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A INPUT -p udp -m udp --dport 137 -j ACCEPT
-A INPUT -p udp -m udp --dport 138 -j ACCEPT
下面重新启动iptables是修改生效:
[root@localhost ~]# /etc/rc.d/init.d/iptables restart。显示ok就行了


最后,启动 Fedora Samba 服务(含两个守护进程:smb,nmb)。

[root@localhost ~]# chkconfig smb on  ← 设置 Fedora Samba 自启动
[root@localhost ~]# chkconfig --list smb  ← 确认 Fedora Samba 启动标签,确认 2-5 为 on 的状态
[root@localhost ~]#chkconfig nmb on  ← 设置 nmb 自启动
[root@localhost ~]## chkconfig --list nmb  ← 确认 nmb 启动标签,确认 2-5 为 on 的状态
nmb 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]#/etc/rc.d/init.d/smb start(或者service smb start)  ← 启动 Fedora Samba 服务
Starting SMB services: [ OK ]
[root@localhost ~]# /etc/rc.d/init.d/nmb start  ← 启动 nmb 服务
Starting NMB services: [ OK ]


测试: 
打开windows。运行——>\\linux的ip地址


posted on 2011-03-16 14:01  dos5gw  阅读(239)  评论(0编辑  收藏  举报