Raspberry Pi


Samba is a key component for our Raspberry Pi setup. In simple terms, it allows us to access the Pi (a Linux environment based on Debian and oterhs) from a Windows machine. It allows us to share things like Printers, and much more.

Samba is an important component to seamlessly integrate Linux/Unix Servers and Desktops into Active Directory environments. It can function both as a domain controller or as a regular domain member.


We use Samba on basically every Raspberry Pi image: to get the Hostname visible in Windows networks, to share files across a Windows network, and more. This article describes how to set it up.

Installing Samba on Raspberry Pi

You can share your Raspberry Pi's files and folders across a network using a piece of software called Samba, a Linux implementation of the Server Message Block protocol. You'll need to install this software:

$ sudo apt install samba samba-common-bin

Samba contains the SMB protocol, support for the Windows naming service (WINS), and support for joining Windows workgroups. A workgroup is a group of computers on a local network that can access eachother's folders. Samba-common-bin contains a tool that you'll need to register users with Samba.

Once these packages have finished installing, you need to edit the Samba configuration file:

$ sudo nano /etc/samba/smb.conf

Find the entries for workgroup and wins support, and set them up as follows:

workgroup = your_workgroup_name
wins support = yes 

The name of the workgroup can be anything you want, as long as it only contains alphabetical characters, and it matches the name of the workgroup that you want to join.

NOTE: if after this you can ping the machine, but cannot connect from windows, it helps to add a new line just below the workgroup setting with your netbios name (I use the same as hostname). Recently, things seem to work without the 'Netbios name' setting though. Ignore this setting if up to now all things work correctly

Netbios name=name of my machine

You also need to add the following section of code to smb.conf:

   comment= Pi Home
   only guest=no
   create mask=0777
   directory mask=0777

Scroll down smb.conf until you see a section called Share Definitions, and add this code there. The path should point to the drive or folder that you want to share. I've set 'only guest' and 'public' to 'no' so that Samba prompts for a password when I visit the folder that I've shared. This means that when I'm using a Windows PC, I can login to the shared folders on my Pi, and I'll have the same read/write permissions that user pi has.

Now type this command in a terminal, and enter pi's password twice (as a sudoer). Notice, that the Samba system has it's own user management.

$ sudo smbpasswd -a pi

If you have a PC or laptop connected to your workgroup, you should be able to see your Raspberry Pi in Windows Explorer under Network.

Extra Settings

  • To disable home directories, commenting them out doesn't seem to work. Instead I use the following setting in smb.conf:
 available = no
  • To restart the Samba service (and enable your configurations you have just edited), use one or another command shown below. Depends on the version of Raspbian you are using.

For older system versions

sudo service samba restart

For system versions as of this writing:

sudo service smbd restart