安装

sudo apt-get update
sudo apt-get install samba samba-common-bin

创建要共享的目录并赋予权限

mkdir /home/pi/share
sudo chmod 777 /home/pi/share

创建用户

smbpasswd -a username

配置conf文件

sudo smbpasswd -a root
sudo smbpasswd -a pi

sudo vim /etc/samba/smb.conf
#在最后添加配置内容

#======================= Global Settings =======================

[global]

## Browsing/Identification ###
   #兼容旧版本电视
   #client min protocol = NT1
   #server min protocol = NT1



[share]
   path = /media
  # valid users = root,pi
   browseable = yes
   public = yes
   writable = yes
   guest ok = yes
   read only = no
   create mask = 0777
   directory mask = 0777
   force create mode = 0777
   directory mask = 0777
   force directory mode = 0777

重启samba

systemctl restart smbd.service

/etc/init.d/smbd restart 

service smb restart

高版本要关闭selinux
1、临时关闭:输入命令setenforce 0,重启系统后还会开启。
2、永久关闭:输入命令vi /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled,然后保存退出。