1.安装samba服务

安装
yum -y install samba
卸载
yum remove samba
查询
rpm -qa | gerp samba

2.启动samba服务

启动
systemctl start smb
关闭
systemctl stop smb
状态
systemctl status smb
开机自启
systemctl enable smb
关闭开机自启
systemctl disable smb

3.配置samba服务

vi /etc/samba/smb.conf
增加[smb]的内容

[global]                                    //全局配置
        workgroup = SAMBA
        security = user

        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 = @printadmin root
        force group = @printadmin
        create mask = 0664
        directory mask = 0775

[smb]                            //这个是共享文件夹标识,表示登录samba打开时显示的文件夹名称。配置了多少个共享文件夹标识,登录samba时就会显示多少文件夹。                                           
       comment = hello samba   //comment是对该共享的描述,可以是任意字符串
       path= /var/ftp           //共享的路径
       writable = yes               //是否可写入
       public = no                  //是否公开

4.创建samba用户

创建用户并指定目录
useradd -d /var/ftp -s /sbin/nologin smb
将smb添加为samba用户
pdbedit -a -u smb

5.防火墙放行samba端口

firewall-cmd --zone=public --add-port=139/tcp --permanent
firewall-cmd --zone=public --add-port=445/tcp --permanent
firewall-cmd --zone=public --add-port=137/udp --permanent
firewall-cmd --zone=public --add-port=138/udp --permanent

关闭selinux

貌似不关也行
setenforce 0

禁止selinux开机启动,将SELINUX=enforcing的值修改为disabled
vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

最后重启防火墙和smb服务
通过运行\ip或者映射访问共享文件