- Raspberry Pi Zero Cookbook
- Edward Snajder
- 545字
- 2021-07-09 19:12:12
Copying different files to and from your home network
Now that your Raspberry Pi Zero is sitting comfortably on your home network, it can work as a central part of it and interact with the other computers using it. This will show you how to set up a file share on your Raspberry Pi that can interact with the computers on your home network.
Getting ready
You can either stay connected to your Zero over SSH, or you can open a terminal in your VNC viewer window-it's all up to you. Because it is rendering graphics, VNC will tend to be a more resource intensive and maybe a little more choppy than your SSH terminal; this recipe does not require any GUI tools to get working.
How to do it...
Samba is really the easiest way to set up a file share if you have Windows machines on your network. While Macs and Linux machines work with Network File Sharing (NFS) very easily, success with using this on Windows operating systems varies quite a bit. Most Home Edition versions of Windows unfortunately do not support acting as an NFS client, but nothing stops us from using Samba:
- First, we will use
apt-get
to get Samba installed:sudo apt-get install samba
- Once this is finished, we will set up a password to connect:
sudo smbpasswd -a pi
- Create a folder that we will use as a file share:
mkdir /home/pi/share
- Let's also make a test file while we're at it:
touch /home/pi/share/helloNetwork.yes
- Now we just need to tell the Samba service about this new share. Open the
/etc/samba/smb.conf
using your favorite editor:sudo vi /etc/samba/smb.conf
- To the end of the file, add your share information:
[share] path = /home/pi/share valid users = pi read only = no
- Save the file, and then restart Samba:
sudo service smbd restart
- Once Samba restarts, it will pick up the new share you entered into the
smb.conf
file. You can check for errors by running this command:testparm
- A truncated version of the expected output is displayed here:
pi@rpz14101:~ $ testparm Load smb config files from /etc/samba/smb.conf Processing section "[homes]" Processing section "[printers]" Processing section "[print$]" Processing section "[share]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions ... [share] path = /home/pi/share valid users = pi read only = No
- If there is anything wrong, this utility should tell you. Otherwise, you should see the new share you just created. If you want to connect from a Linux or Mac computer, the address will be in this format:
smb://<IP_Address>/shareName
- In my case, it is this:
smb://192.168.2.42/share
On a Windows machine, you connect to
\\IP_Address\ShareName
, as in\\192.168.2.42\share
.A login prompt should appear; use the name and password you provided in
smbpasswd
: - If all went well, you should see the file you created earlier:
Now you can read and write into and out of that folder. This is a great way to copy a backup of files you've created on your Raspberry Pi Zero in case you decide you want to start with a fresh SD card. For future recipes where we will write programs and scripts, we will work in this directory so that it is easy to make a backup.
- 后稀缺:自動(dòng)化與未來(lái)工作
- 課課通計(jì)算機(jī)原理
- Ansible Configuration Management
- Hands-On Internet of Things with MQTT
- Getting Started with Oracle SOA B2B Integration:A Hands-On Tutorial
- STM32G4入門(mén)與電機(jī)控制實(shí)戰(zhàn):基于X-CUBE-MCSDK的無(wú)刷直流電機(jī)與永磁同步電機(jī)控制實(shí)現(xiàn)
- 項(xiàng)目管理成功利器Project 2007全程解析
- The DevOps 2.1 Toolkit:Docker Swarm
- 貫通開(kāi)源Web圖形與報(bào)表技術(shù)全集
- 工業(yè)機(jī)器人集成應(yīng)用
- PHP求職寶典
- 大數(shù)據(jù)時(shí)代的調(diào)查師
- PowerPoint 2003中文演示文稿5日通
- SQL Server 2019 Administrator's Guide
- Microsoft Power BI Complete Reference