yum install -y samba
#创建samba用户
useradd samba
#添加 Samba 用户
smbpasswd -a samba
123456
// 添加 Samba 用户帐号
# smbpasswd -a sambauser
// 禁用 Samba 用户帐号
# smbpasswd -d sambauser
// 启用 Samba 用户帐号
# smbpasswd -e sambauser
// 删除 Samba 用户帐号
# smbpasswd -x sambauser
查看配置文件
cat /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 #samba的工作组,设置成 Windows 的工作组
security = user #安全选项,可以是 share|user|server|domain,安全级别递增
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[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 = root
create mask = 0664
directory mask = 0775
[rootdir] #自定义的共享文件夹
comment = SambaRoot
path = /home/samba/ #共享的路径
read only = No
编辑配置文件
vi /etc/samba/smb.conf
#创建共享目录
mkdir -p /data/samba/
#更改权限
chown samba:samba /data/samba/
cat >> /etc/samba/smb.conf <<EOF
[rootdir]
comment = SambaRoot
path = /data/samba/
read only = No
EOF
启动 Samba 服务
systemctl start smb
systemctl stop smb
systemctl status smb
#WIN+R 输入或者直接在文件夹路径框输入双反斜杠 + ip地址
\\192.168.199.117
输入刚设置的用户名和密码samba、123456
Samb 还需要开放下面四个端口
UDP 137、UDP 138、TCP 139、TCP 445