samba服务搭建
xy12306 Lv2

samba服务搭建

一、关闭防火墙

1
2
3
4
5
6
7
# 关闭防火墙
systemctl stop firewalld
# 禁止防火墙开机自启动
systemctl disable firewalld
# 查看防火墙状态
systemctl status firewalld
setenforce 0

vim /etc/sysconfig/selinux
将未注释的SELINUX行的值改为disabled
SELINUX=disabled

二、安装samba与配置

1. 安装与启动

1
2
3
4
5
6
7
yum install -y samba

# 启动samba并设置开机自启动
systemctl enable smb
systemctl enable nmb
systemctl start smb
systemctl start nmb

2. 相关配置

  • 创建共享文件夹及测试文件
1
2
3
4
5
mkdir -p /smb/share
chmod 777 /smb/share

cd /smb/share
echo 'Hello World' > 1.txt

vim /etc/samba/smb.conf

  • 在结尾处添加以下内容
1
2
3
4
5
6
7
[share]                       
comment = share
path =/smb/share
browseable = yes
read only = no
writeable = yes
public = Yes
  • 添加用户并启动服务 请记住设置的密码
1
2
3
4
5
6
7
8
9
10
11
# 添加用户并设置密码 
useradd user01
smbpasswd -a user01

# 重启服务
systemctl restart smb
systemctl restart nmb

# 查看服务是否启动
systemctl status smb
systemctl status nmb

三、window端访问测试

在物理机中使用 win+R 调出运行窗口,按照图片输入samba服务器ip地址后弹出登录界面,输入用户和密码即可!

image

登录成功后,即可在共享文件夹中看到文件


注 : 仅适用于初学者参考使用

 请作者杯咖啡
由 Hexo 驱动 & 主题 Keep
访客数 访问量