Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi cookbook for Python programmers

You're reading from   Raspberry Pi cookbook for Python programmers The Raspberry Pi Cookbook has over 50 tailor-made recipes for programmers to get the most out of Raspberry Pi using Python to unleash its huge potential.

Arrow left icon
Product type Paperback
Published in Apr 2014
Publisher
ISBN-13 9781849696623
Length 402 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (18) Chapters Close

Raspberry Pi Cookbook for Python Programmers
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with a Raspberry Pi Computer FREE CHAPTER 2. Starting with Python Strings, Files, and Menus 3. Using Python for Automation and Productivity 4. Creating Games and Graphics 5. Creating 3D Graphics 6. Using Python to Drive Hardware 7. Sense and Display Real-world Data 8. Creating Projects with the Raspberry Pi Camera Module 9. Building Robots 10. Interfacing with Technology Hardware and Software List Index

Sharing the home folder of the Raspberry Pi with SMB


When you have the Raspberry Pi connected to your network, you can access the home folder by setting up file sharing; this makes it much easier to transfer files and provides a quick and easy way to back up your data. Server Message Block (SMB) is a protocol that is compatible with Windows file sharing, OS X, and Linux.

Getting ready

Ensure that you have the Raspberry Pi powered and running with a working connection to the Internet.

You will also need another computer on the same local network to test the new share.

How to do it…

First, we need to install samba, a software that handles folder sharing in a format that is compatible with Windows sharing methods.

Ensure that you use update as follows to obtain the latest list of available packages:

sudo apt-get update
sudo apt-get install samba

The install will require around 20 MB of space and take a few minutes.

Once the install has completed, we can make a copy of the configuration file as follows to allow us to restore to defaults if needed:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
sudo nano /etc/samba/smb.conf

Scroll down and find the section named Authentication; change the # security = user line to security = user.

As described in the file, this setting ensures that you have to enter your username and password for the Raspberry Pi in order to access the files (this is important for shared networks).

Find the section called Share Definitions and [homes], and change the read only = yes line to the read only = no line.

This will allow us to view and also write files to the shared home folder. Once done, save and exit by pressing Ctrl + X, Y, and Enter.

Note

If you have changed the default user from pi to something else, substitute it in the following instructions.

Now, we can add pi (the default user) to use samba as follows:

sudo pdbedit -a -u pi

Now, enter a password (you can use the same password as your login or select a different one, but avoid using the default Raspberry password, which would be very easy for someone to guess). Restart samba to use the new configuration file as follows:

sudo /etc/init.d/samba restart
[ ok ] Stopping Samba daemons: nmbd smbd.
[ ok ] Starting Samba daemons: nmbd smbd.

In order to test, you will need to know either the Raspberry Pi's hostname (the default hostname is raspberrypi) or its IP address. You can find both of these with the following command:

hostname

For the IP address, add -I as follows:

hostname –I

On another computer on the network, enter the \\raspberrypi\pi address in the explorer path.

Depending on your network, the computer should locate the Raspberry Pi on the network and prompt for a username and password. If it can't find the share using the hostname, you can use the IP address directly, where 192.168.1.69 should be changed to match the IP address, \\192.168.1.69\pi.

You have been reading a chapter from
Raspberry Pi cookbook for Python programmers
Published in: Apr 2014
Publisher:
ISBN-13: 9781849696623
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime