Share files between RPi and your Laptop using Samba

Subscribe to my newsletter and never miss my upcoming articles

If you work on a RPi and want to understand about a way to share a folder between your RPi and your laptop, be it Linux or Windows then you have landed on the right page. 😇

This blog assumes that you are able to SSH into your RPi and have the appropriate permissions to install softwares. 😀

Let's start 🙌🏻

So what is Samba btw, so Samba is a collection of applications that implements the SMB protocol, SMB protocol is in turn a protocol that is used to read and write files over the LAN.

SMB works on a client-server architecture where you configure the server(Rpi in our case) to make the files available over the network and by doing so all the clients attached on the network can get the access to the files share by the server.

image.png

Now, NFS is clearly a better alternative of sharing files over the network but since SMB is the default protocol for windows ecosystem we will be using SMB to support Linux-Windows kind of sharing too.🥴

Lets see it in action 🥵

Note- The below steps would work the same for a windows machine too.

Install SAMBA on the RPi

sudo apt-get update
sudo apt-get install samba # Answer Yes to DHCP 
sudo apt-get install samba-common-bin

Create a folder to share (Lets name it assets)

mkdir assets

Configure Samba

Open the config file

sudo nano /etc/samba/smb.conf

And add the following sections .

Firstly we are going to create workgroup over which the file will be shared

workgroup = WORKGROUP
#wins support = yes         #Uncomment this line if you are using windows OS

Secondly we will configure the directory that we want to share and give it correct permissions, beware that we are giving 0777 permissions 🤡 to the directory which means everyone has the read,write and execute permissions over this folder. 😈

[MyFolder]
 comment=Raspberry Pi Share
 path=/home/pi/assets
 browseable=Yes
 writeable=Yes
 only guest=no
 create mask=0777
 directory mask=0777
 public=no

Configure a user for SAMBA on the server (RPi in our case) 😁

sudo smbpasswd -a pi

After which it will ask you to set a password for the user.

Test if everything is alright and restart the samba service 🤗

testparm
sudo service smbd restart

Connect to the server from your laptop like this

image.png

Thanks !! 🤗🤗🤗

No Comments Yet