Skip to main content
  1. Posts/

Setting Up Samba on a Raspberry Pi

·360 words· 0 · 0 · ·
tutorial samba file server nas

Samba is one of the go-to protocols for sharing files over a network.

It is builtin to Windows, but needs to be installed and configured on other OSes like Linux and macOS.

Thankfully the process is not too difficult.

Installing on Rasbian>

Installing on Rasbian #

Run the following command on your Pi to install a samba server and client onto your Pi.

sudo apt update && sudo apt install samba samba-common-bin smbclient cifs-utils
Checking the smb server>

Checking the smb server #

To check the status of your smb server, use:

systemctl status smbd
Configuring Samba>

Configuring Samba #

Making a user>

Making a user #

Samba users are different from Unix/Linux users, so we must create a new user with the smbpasswd command

sudo smbpasswd -a pi

It should ask for a password for the new user before adding them

Network Shares, Permissions configuration>

Network Shares, Permissions configuration #

The main configuration file for samba is located at /etc/samba/smb.conf. This is where you configure which folders/files are shared, what permissions they have (client side), whether they are public, and more.

Let’s assume you have a folder /home/pi/share that has files you want to share. You can create this by doing mkdir -m 1777 /home/pi/share

If you wanted samba to share this directory, you would need something like this in your smb.conf:

   path = /home/pi/share
   create mask=0777
   directory mask=0777

Note: always make sure to restart samba after changing configurations

systemctl restart smbd
Mounting a smb share on Linux>

Mounting a smb share on Linux #

mount -t cifs -o username=pi //<ip of server>/myshare /mnt/share
Mapping a smb share as a drive on Windows>

Mapping a smb share as a drive on Windows #

With File Explorer>

With File Explorer #

  1. Open File Explorer

  2. Click “This PC”

  3. In the ribbon view click “Map network drive”


  1. Enter \\<ip of server>\share for the folder (you can do this in File Explorer too)


  1. Enter the user and password credentials setup earlier

  2. The share should be mapped

With CMD.exe>

With CMD.exe #

net use Z: \\<ip of server>\folder
With PowerShell>

With PowerShell #

New-SmbMapping -LocalPath 'Z:' -RemotePath '\\<ip of server>\folder'