Home Learning Share a folder with a Windows computer from a Raspberry Pi

Share a folder with a Windows computer from a Raspberry Pi

by shedboy71

Sharing files over the network is incredibly handy, when I was writing code examples to publish on this site it was useful to run them on the Raspberry PI, copy them to a folder which could be accessed on my Windows 7 PC.
Install and configure required software

To share network folders to a Windows computer we need to install some special software on the Raspberry Pi. The software providing the secret sauce this time is called Samba. The Samba software package implements the SMB protocol and provides support for the Windows naming service (WINS) and for joining a Windows Workgroup.

Installing the software is easy – login to your Raspberry Pi and run the following:

sudo apt-get install samba samba-common-bin

After installation configure the software by opening the file /etc/samba/smb.conf using the command:
sudo nano /etc/samba/smb.conf

Read through the file and make sure you have the following parameters set, on my one win support was no and commented out:

workgroup = WORKGROUP
wins support = yes

You can use anything as your workgroup name as long as it is alphanumerical and matches the workgroup you would like to join. The default workgroup in Windows 7 is WORKGROUP.

Setup folder to share

Next step is to create the folder you would like to share. To create a folder called “myshare” in your home directory do the following:

mkdir ~/myshare

With the folder created we can now tell the Samba software to share it on the network. Open the file /etc/samba/smb.conf using the command:

sudo nano /etc/samba/smb.conf

Scroll to the bottom and add the following:

comment=Raspberry Pi Share
only guest=no
create mask=0777
directory mask=0777

Notice how we tell Samba that public access is not allowed via “public=no” – this means that anyone wanting to access the shared folder must login with a valid user.

In this case the valid user is the user called “pi”. To let Samba know that “pi” is a network user run the command:
sudo smbpasswd -a pi
And enter pi’s password twice (default: raspberry).

At this point we can now login to the share from our Windows computer – use Domain: raspberrypi, User: pi and Password: raspberry

If you do not to have to log in all of the time you can always make the share publicly available by changing the config file to say:

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More