Set Up a Local File Sharing Server on Raspberry Pi 4 B

Simon Huang

Simon Huang

@simon

The latest Raspberry Pi 4B comes with a Gigabyte ethernet port, up to 4GB RAM and 2 USB3 port. Because of its low power supply, Raspberry Pi 4 surely has the capability of working as an affordable file server to back up and share files from anywhere on your local network. In other words, all your local devices have can not only backup your important files to the Raspberry Pi, but also plays movies stored in the Raspberry Pi. You can even plug external drives to it to enlarge the disk space. In this tutorial, we will use Samba to set up a file server on your Raspberry Pi 4.

Samba?

Samba is the Linux implementation of the SMB/CIFS file sharing standard used by Windows PCs and Apple computers, and widely supported by media streamers, games consoles and mobile apps. With Samba activated you can quickly copy files from a computer on your network to a Raspberry using wireless LAN (or a direct Ethernet connection).

Installation

First we need to update and upgrade the apt source and package list:

sudo apt-get update
sudo apt-get upgrade

Then we can install the Samba:

sudo apt-get install -y samba-common-bin
sudo apt-get install -y samba

Configuration

First we create a folder under pi:

sudo mkdir -m 1777 /home/pi/share

Now we need to modify the configuration of Samba:

# backup the original configuration file
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
# edit the configuration file
sudo vim /etc/samba/smb.conf
# add the following content at the end
# =====================
[share]
comment = Raspberry Pi Shared Folder
path = /home/pi/share/
valid users = pi
public = yes
browseable = yes
writable = yes
create mask = 0777
directory mask = 0777
only guest = no

type “I” to insert; use “:wq” to save and exit in vim

reference: https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html

Give the share folder full permission:

sudo chmod -R 777 /home/pi/share

Change the default Samba password for user pi:

sudo smbpasswd -a pi

Lastly, we need to restart the Samba service to apply all changes:

sudo /etc/init.d/smbd restart

Connection

You’ll now be able to find your Raspberry Pi file server (named RASPBERRYPI by default) from any device on your local network. If you’ve left smb.conf’s default settings as they are, it will appear in a Windows network workgroup called WORKGROUP.

Sometimes you will need to reboot your other devices if you modify the configuration file later.

Further Discussion

  1. Ideally you might want to connect your Raspberry Pi to the local network through the Gigabyte ethernet port since the WiFi may not work as fast and stable as the ethernet cable. Also make sure to use CAT.5E or CAT.6 ethernet cable and your router also has Gigabyte port.
  2. If you want to expand your disk space by plugging in external USB drives, make sure the disk is correctly mounted by Raspberry Pi and condifured in smb.conf.
Fizzy

© 2025 Fizzy All Rights Reserved.