Centos7配置samba

本文详细介绍了如何在CentOS7上配置Samba服务,包括关闭selinux和firewall,编辑smb.conf配置文件,创建Samba用户,启动和设置Samba服务开机启动。通过这些步骤,可以使得Windows系统能够访问Linux的共享目录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SAMBA: Linux下的一个服务,作用:在Linux服务器上设置一个共享目录,让Windows主机上可以访问(rw)这个目录

Centos7 配置 SAMBA步骤:

一、关闭selinux和firewall

关闭selinx:SELINUX=enforcing 改为 SELINUX=disabled

在这里插入图片描述

关闭firewall:systemctl stop firewalld

禁止防火墙开机启动:systemctl disable firewalld

在这里插入图片描述

二:配置SAMBA

进入/etc/samba/smb.conf

# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
	workgroup = SAMBA
	security = user

	passdb backend = tdbsam

	printing = cups
	printcap name = cups
	load printers = yes
	cups options = raw
	map to guest = Bad User
	guest ok = yes

[homes]
	comment = Home Directories
	valid users = %S, %D%w%S
	browseable = No
	read only = No
	inherit acls = Yes

[printers]
	comment = All Printers
	path = /var/tmp
	printable = Yes
	create mask = 0600
	browseable = No

[print$]
	comment = Printer Drivers
	path = /var/lib/samba/drivers
	write list = @printadmin root
	force group = @printadmin
	create mask = 0664
	directory mask = 0775

[share]
	comment = My Samba
	path = /home/user/share
	browseable = yes
	writerable = yes

添加SAMBA用户

smbpasswd ‐a user 此时设置的密码是windows访问此目录时要输
入的密码。
在这里插入图片描述

启动Samba服务,输入命令 systemctl start smb

设置samba开机启动 systemctl enable smb.service

三、Windows下访问linux共享目录

在这里插入图片描述
在这里插入图片描述
可以看到此时的目录是linux下的目录
在这里插入图片描述

如果出现以下情况:

在这里插入图片描述
解决方案
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值