打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
CentOS 5架设配置Samba服务器
CentOS 5架设配置Samba服务器(Windows与Linux文件共享)
发表于118 天前 ? FAQ ? 暂无评论

Windows与Windows系统之间可以很容易的共享文件。但要Windows与Linux共享文件则需要架设Samba服务器。Samba通过SMB协议,可以实现Windows与Linux之间的文件共享。这里我们主要介绍如何安装配置Samba服务器以及添加Samba用户。

安装Samba服务器之间,需要关闭SELinux。

安装Samba

  1. yum install cups-libs samba samba-common

编辑smb.conf配置文件

  1. vi /etc/samba/smb.conf

请确保在配置文件中的[globle]区域看到如下代码,如果没有自行添加。

  1. [...]
  2. # Backend to store user information in. New installations should
  3. # use either tdbsam or ldapsam. smbpasswd is available for backwards
  4. # compatibility. tdbsam requires no further configuration.
  5.  
  6.         security = user
  7.         passdb backend = tdbsam
  8. [...]

这主要是使Linux系统用户能够登录Samba服务器。
现在设置开机启动并启动Samba服务器。

  1. chkconfig --levels 235 smb on
  2. /etc/init.d/smb start

设置共享文件夹

下面设置的文件夹对所有用户可进入。
建立文件夹/home/shares/allusers并设置权限。

  1. mkdir -p /home/shares/allusers
  2. chown -R root:users /home/shares/allusers/
  3. chmod -R ug+rwx,o+rx-w /home/shares/allusers/

编辑smb.conf配置文件并在文件末尾增加如下代码:

  1. vi /etc/samba/smb.conf
  1. [...]
  2. [allusers]
  3.   comment = All Users
  4.   path = /home/shares/allusers
  5.   valid users = @users
  6.   force group = users
  7.   create mask = 0660
  8.   directory mask = 0771
  9.   writable = yes

如果你希望所有用户能够通过Samba服务器读写他们自己的根目录,可以在/etc/samba/smb.conf文件增加如下代码(确保你已经注释或删除其它的 [homes]区域代码)。

  1. [...]
  2. [homes]
  3.    comment = Home Directories
  4.    browseable = no
  5.    valid users = %S
  6.    writable = yes
  7.    create mask = 0700
  8.    directory mask = 0700

现在重启Samba服务器。

  1. /etc/init.d/smb restart

添加Samba用户

第一步我们先增加系统用户tom,如果你想使用已存在的系统用户,可以略过此步。

  1. useradd tom -m -G users
  2. passwd tom

第二步将tom系统用户添加到Samba用户数据库。

  1. smbpasswd -a tom

键入tom的密码(可以与系统密码不同)。
现在你通过Windows的文件管理器,在文件管理器地址栏输入 \\192.168.1.1(此为服务器的IP),在跳出的对话框输入tom及tom的密码就可以登录Samba服务器,与Linux系统共享文件了。
需要了解更多Samba的资料请访问:http://www.samba.org/

CentOS Linux交流群:177361427,欢迎博客读者们加入交流

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
搭建Samba服务器
ubuntu 16.04 Samba服务器搭建
ftp服务器(ftp/tftp)、 Samba服务器、NFS服务器的区别
Ubuntu和windows实现文件共享
7.1.1 Samba服务概述
SAMBA配置详解
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服