How to Setup an SMB (SAMBA) Share on a Raspberry Pi

Listen to this Post

Network file sharing is essential for quick and easy access to files across devices. In this guide, we’ll walk through setting up an SMB (SAMBA) share on a Raspberry Pi, allowing seamless file transfers over your local network.

Prerequisites

  • Raspberry Pi (any model)
  • Raspberry Pi OS installed
  • Network connection
  • Basic Linux command knowledge

Step-by-Step Setup

1. Update Your System

Before installing Samba, ensure your system is up to date:

sudo apt update && sudo apt upgrade -y

#### **2. Install Samba**

Install the Samba package:

sudo apt install samba samba-common-bin -y

#### **3. Configure Samba**

Edit the Samba configuration file:

sudo nano /etc/samba/smb.conf

Add the following at the end of the file (replace `sharename` and `path/to/share` with your desired settings):

[sharename] 
path = /path/to/share 
browseable = yes 
writable = yes 
guest ok = yes 
create mask = 0777 
directory mask = 0777 

Save (`Ctrl+O`) and exit (`Ctrl+X`).

#### **4. Create the Shared Directory**

sudo mkdir -p /path/to/share 
sudo chmod -R 777 /path/to/share 

#### **5. Restart Samba**

Apply changes by restarting the Samba service:

sudo systemctl restart smbd 

#### **6. Access the Share from Another Device**

On Windows:

  • Open File Explorer → Enter `\\raspberrypi-ip\sharename`

On Linux/macOS:

  • Use `smb://raspberrypi-ip/sharename` in the file manager.

### **You Should Know:**

#### **Securing Your Samba Share**

If you want to restrict access, use a password-protected share:

1. Set `guest ok = no` in `smb.conf`.

2. Add a Samba user:

sudo smbpasswd -a pi 

(Replace `pi` with your username.)

#### **Checking Samba Status**

sudo systemctl status smbd 

#### **Firewall Rules (If Using UFW)**

sudo ufw allow samba 

#### **Mounting Samba Share Permanently (Linux)**

Add to `/etc/fstab`:

//raspberrypi-ip/sharename /mnt/samba cifs username=pi,password=yourpass 0 0 

### **What Undercode Say**

Setting up an SMB share on a Raspberry Pi is a great way to create a simple, efficient file-sharing system. Samba is versatile and works across Windows, Linux, and macOS. For better security, always use strong passwords and consider encrypting sensitive files.

#### **Bonus Commands:**

  • List connected Samba users:
    sudo smbstatus 
    
  • Test Samba config before restarting:
    testparm 
    
  • Remove a Samba user:
    sudo smbpasswd -x username 
    

### **Expected Output:**

A fully functional Samba share accessible across your network.

Reference: Samba Setup Guide

References:

Reported By: Chuckkeith Sometimes – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image