#### [[返回文档目录]](../index.html) [[查看原始页]](../content/%E5%9C%A8%E6%A0%91%E8%8E%93%E6%B4%BE%E4%B8%8A%E5%90%AF%E7%94%A8samba%E6%9C%8D%E5%8A%A1%EF%BC%88%E5%9C%A8%E7%94%B5%E8%84%91%E4%B8%8Epi%E9%97%B4%E4%BA%92%E4%BC%A0%E6%96%87%E4%BB%B6%EF%BC%89Raspberry%20Pi.html) # 在树莓派上启用samba服务(在电脑与pi间互传文件)Raspberry Pi *本帖最后由 血染盔甲 于 2012-12-25 17:28 编辑* 针对powerdruy所提的问题,决定把本文来个大改动 参考这两篇文http://man.lupaworld.com/content/linux/Debian\_server\_setting/smb.html#4.4 http://www.debianadmin.com/file-server-configuration-in-debian-using-samba.html 本文只是对samba的最基本的配置,即利用samba来实现电脑读写树莓派间上指定文件夹内的文件,更多samba服务器的内容等待大家去挖掘。 步骤如下: sudo apt-get install samba sudo apt-get install samba-common-bin 安装完成后,我们在/ect/samba/文件夹中找到这个文件smb.conf,它是用来对samba服务配置用的,用nano文件编辑器打开后发现里面很是复杂,没关系,我们只需要一个简单smb.conf。先将smb.conf重命名为smb.conf.backup。然后用下面的smb.conf替换原来的smb.conf <table bgcolor="#ffff66" cellspacing="0" style="width: 740px; background-image: none; background-attachment: scroll; background-origin: padding-box; background-clip: border-box; background-color: rgb(255, 255, 102); background-size: auto; border: 1px solid rgb(227, 237, 245); color: rgb(68, 68, 68); display: table; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: 19px; font-family: Tahoma, 'Microsoft Yahei', Simsun; height: 156px; margin: 0px; outline: rgb(68, 68, 68) none 0px; padding: 0px; text-decoration: initial; word-wrap: break-word; background-position: 0% 0%; background-repeat: repeat repeat;"><tbody style="border: 0px none rgb(227, 237, 245); color: rgb(68, 68, 68); display: table-row-group; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: 19px; font-family: Tahoma, 'Microsoft Yahei', Simsun; height: 156px; margin: 0px; outline: rgb(68, 68, 68) none 0px; padding: 0px; text-decoration: initial; vertical-align: middle; width: 740px; word-wrap: break-word;"><tr style="border: 0px none rgb(227, 237, 245); color: rgb(68, 68, 68); display: table-row; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: 19px; font-family: Tahoma, 'Microsoft Yahei', Simsun; height: 156px; margin: 0px; outline: rgb(68, 68, 68) none 0px; padding: 0px; text-decoration: initial; vertical-align: middle; width: 740px; word-wrap: break-word;"><td style="border: 1px solid rgb(227, 237, 245); color: rgb(68, 68, 68); display: table-cell; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: 21px; font-family: Tahoma, 'Microsoft Yahei', Simsun; height: 147px; margin: 0px; outline: rgb(68, 68, 68) none 0px; overflow: hidden; padding: 4px; text-decoration: initial; vertical-align: middle; width: 731px; word-wrap: break-word;">[global]<br/>         log file = /var/log/samba/log.%m<br/> [tmp]<br/>         comment = Temporary file space<br/>         path = /tmp<br/>         read only = no<br/>         public = yes<br/> </td></tr></tbody></table> 保存完毕后输入命令: sudo /etc/init.d/samba retsart 这条命令是重启samba服务,为使刚刚重新设置的配置文件生效。 这时打开电脑上的网上邻居(要保证你的电脑和树莓派在同一局域网内),你就会看到名为RASPBERRYPI这个主机了,尝试打开,发现需要用户名与密码,但是现在无论输入什么用户名与密码都进不去,因为我们还没有设置呢!O(∩\_∩)O,那下面就来创建用户吧。 ![@}WKY)1FS9536GW6YCIM5[N.jpg](http://files.note.sdo.com/M5cEN~kg7EOFnM24s00NZw "@}WKY)1FS9536GW6YCIM5[N.jpg") *(外链图片未本地化)* 2012-12-25 17:10 上传 [**下载附件** (79.34 KB)](http://www.eeboard.com/bbs/forum.php?mod=attachment&aid=MTM3Nzh8YmZlNjlmZDV8MTM1OTA3OTU0OHwwfDU0NzM%3D&nothumb=yes "@}WKY)1FS9536GW6YCIM5[N.jpg 下载次数:0") 由于创建的samba用户需要是系统内已经存在的用户,而系统默认是只有root和pi这两个用户的,如果想使用其他的用户名怎么办,新建一个呗(假设我们要新建一个用户名为aaa的用户) 输入命令: sudo useradd aaa 这时系统就新建了一个名为aaa的用户,但不是我们samba还没有设置呢,别急,看下面 在/etc/samba/文件夹下建立smbpasswd文件,命令为: sudo touch /etc/samba/smbpasswd 再给samba添加用户名为aaa的用户:sudo smbpasswd -a aaa 会让你输入密码的,自己设一个,设完了会显示:Added user aaa 到这里就搞定了,再打开网上邻居,输入刚刚设好的用户名与密码,这时就进去了,会发现一个tmp的文件夹,可以在这个文件夹内自由地读写数据了,比如说传电影,考电影,传歌,考歌等等,反正你懂得啦。贴张图: ![YX3{TZ0M64DFO[DI%{9XU72.jpg](http://files.note.sdo.com/M5cEN~kg7EOFnM24s00NZu "YX3{TZ0M64DFO[DI%{9XU72.jpg") *(外链图片未本地化)* 2012-12-23 12:40 上传 [**下载附件** (63.02 KB)](http://www.eeboard.com/bbs/forum.php?mod=attachment&aid=MTM2NDJ8N2Q3NTljNTF8MTM1OTA3OTU0OHwwfDU0NzM%3D&nothumb=yes "YX3{TZ0M64DFO[DI%{9XU72.jpg 下载次数:0") 欢迎大家测试,也希望有问题一起解决! [【分享】](thread-5473-1-1.html)