First we need to install Samba on the Pi. Follow the steps below to do it.
# Refresh package list sudo apt-get update # Upgrade installed packages, you may want to use full-upgrade to remove unused packages sudo apt-get upgrade # Install the required packages sudo apt-get install samba
Create shared folder
We need a place to put our files we want to share. You may choose a different location, but I decided to put a directory called shared to the root.
sudo mkdir -m 1777 /shared
By setting 777 we grant read, write and execution permissions to everybody. Additionally, we set the sticky bit to 1, this ensures that only owners of files in the directory can delete or change them.
Configure Samba to use the shared folder
To enable the new folder to be accessed using a Windows PC we need to update the Samba configuration.
Add the following code at the end of the configuration file /etc/samba/smb.conf.
[shared] Comment = Shared folder Path = /shared Browseable = yes Writeable = Yes only guest = no create mask = 0777 directory mask = 0777 Public = yes Guest ok = no
Add a user to Samba
We add a new user to Samba for security reasons. You could set Guest ok = yes in the configuration above to enable anonymous access.
sudo smbpasswd -a pi
Restart Samba to set the changes effective.
sudo /etc/init.d/smbd restart