linux中搭建samba服务,实现局域网中文件共享
Samba is a free software that implements the SMB protocol on Linux and UNIX systems, consisting of servers and client programs. SMB (Server Messages block, information service blocks) is a kind of communication protocol for sharing files and printers on LAN, which provides shared services of files and printers among different computers in LAN.
实验环境:Linux6、虚拟windows7/10、yum仓库、同一网段。`rpm -q samba` //查看Samba安装与否 `yum install /mnt/Packages/samba-3.6.9-164.el6.x86_64.rpm` //需要安装的samba包 `rpm -qc samba ` //看samba配置路径 `cd /etc/samba` //进入配置路径查看信息
`mv smb.conf smb.conf.bk‘ ` // 重命名配置文件`grep -v "#" smb.conf.bk >smb.conf` //反向过滤掉带#的注释内容`vim smb.conf` //进入配置文件中进行编辑末行模式 set nu 查看行数命令模式/security 找到后将user改成share命令模式G到行尾命令模式o下一行插入`[share]` //文件名`path=/opt/share` //定义路径`public=yes ` //共享`browseable=yes ` // 可访问的权限`writable=yes` //可写入的权限`create mask=0644` // 创建文件自身权限`directory mask=0755` //创建文件夹自身权限`setenforce 0 ` //关闭安全组件`service iptables stop` //关闭防火墙`service smb start` //开启服务cd /optmkdir sharecd share/echo "this is share" >share.txtls可以看到有一个share.txt文件下面进入虚拟windows进行验证
Thank you for reading ~
The Samba server is configured in Linux to enable file sharing on the LAN.