10树莓派Samba的安装与配置

时间:2021-08-29 15:34:26

2017-08-31 12:28:26

1.安装samba服务
打开终端或者SSH连接树莓派,输入如下命令:

sudo apt-get install samba

已经安装过了显示下列信息:

pi@raspberrypi:~ $ sudo apt-get install samba
Reading package lists... Done
Building dependency tree
Reading state information... Done
samba is already the newest version (2:4.5.8+dfsg-2+deb9u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo apt-get install samba
sudo apt-get install smbclient 后来手动安装了这个

sudo apt-get remove --purge smbclient 删除包,包括删除配置文件等;后来手动卸载了这个

2.编辑samba主配置文件
sudo nano /etc/samba/smb.conf
在文件的结尾输入这些

[PI_homeassistant]
path = /home/homeassistant/.homeassistant
comment = No comment
browsable = yes
read only = no
valid users =
writable = yes
guest ok = yes
public = yes
create mask = 0777
directory mask = 0777
force user = homeassistant
force create mode = 0777
force directory mode = 0777
hosts allow =lo 192.168.0. 192.168.1. 192.168.99.

#lo配置多个允许的网段,使用空格分开

Ctrl+O写入文件,Ctrl+X退出nano编辑器。

3.重启samba服务
sudo service samba restart

service samba
Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload|status}

其他:Samba服务器的启动、关闭和重
安装完成后,可以cd到/etc/init.d/目录下,查找smbd命令,然后执行如下命令:
启动Samba服务器:#sudo /etc/init.d/smbd start
关闭Samba服务器:#sudo /etc/init.d/smbd stop
重新启动Samba服务器:#sudo /etc/init.d/smbd restart

另外: 
增加samba用户:
sudo smbpasswd -a pi
输入两次密码,建议与系统保持一致。

关于samba配置文件更多详细介绍见文章:
Samba配置文件常用参数详解 http://yuanbin.blog.51cto.com/363003/115761/

如果Windows无法找到配置目录,请参考http://jingyan.baidu.com/article/c33e3f4880583eea15cbb52b.html

\\192.168.1.2\config