# Connecting raspberry pi folder to Windows as a Network Device using Samba. ___ [Tutorial](https://fernandezvictor.medium.com/raspberry-pi-as-samba-server-to-create-shared-folder-between-computers-cdea979092b8) First, you need to install samba into your raspberry pi. After doing that, you run I do this every time I work with Linux or raspberry pi, and I advise you to do it too. ``` sudo apt-get update sudo apt-get upgrade ``` Next, let’s get samba. ``` sudo apt-get install samba samba-common-bin ``` #### Prepare the shared directory/folder Now we need to define the folder/directory we are going to use, this will be the folder that PC A and B will have access to. The folder can be located anywhere, even in an external folder. the SDcard I was using died a few days after and because I set the folder in a thumb drive I didn’t last the information, I just need it to bake another SDCard install samba and I was up and running. ``` mkdir /home/pi/shared ``` Access configuration The next step is to modify the file smb.conf to let samba knows where the folder to share is and how to handle the access. ``` sudo nano /etc/samba/smb.conf ``` at the end of the file add: ``` [pimyshare] path = /home/pi/shared writeable=Yes create mask=0777 directory mask=0777 public=no ``` 1. [pimyshare] the text in brackets defines the point where we will access the folder itself, for example //raspberrypi/pimyshare. this will be important later when we configure PC a and B to access the folder. 2. path is the path to the directory we are going to share. 3. writeable set as yes allow the user to write in the folder (we need this to add new files to the folder). 4. create mask and directory mask define the permission for both folder and files, it is set as 07770777 users are allowed to read, write and execute (some cases will be better to avoid the execution for security reasons). 5. public set to no it will require a valid user to grant access to the folder. Save the document in this case Ctrl + X and Y . Set a user for the samba share To control the access to this folder, I add a user and a password. With this command we can set the password, the user will be pi ``` sudo smbpasswd -a pi ``` Restart the server. ``` sudo systemctl restart smbd ``` If we need to get the hostname, we can obtain it with ```hostname -I``` ### Connect to the Samba server The final step is to configure access to the shared directory. Windows File Explorer > Computer > Map network drive Now we need to input the name of the host or the IP address followed by the name of the folder ( name in brackets in the configuration file) The system will ask you for the user and password, as explained in a previous step the user is “pi” and the password was the one defined before.