Share a folder via Samba on Raspberry Pi 3

Share a folder from Raspbian 9 (stretch) is pretty simple.

Check samba status

You need to check if samba already installed and running.

Type in your terminal:

$ samba --version

The output must be the version number of the installed samba version:

$ Version 4.5.12-Debian

To check if it’s running, type (you mast be root or sudoers):

$ sudo smbstatus

If samba is running it will show different information on the service PID, user, machine, shred folders and so on. In this case skip the next paragraph.

Install samba server

If samba is not correctly installed type (you mast be root or sudoers):

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

Configure your samba server

It’s now time to configure your samba server.

Let’s go to edit the smb.conf located in /etc/samba (I’ll use nano editor). Type:

$ sudo nano /etc/samba/smb.conf

Change the following entries:

workgroup=WORKGROuP  # This must be set with your workgroup. Leave if you don't know.
wins support=yes # Wins is support to Windows machine. Leave if you don't need it.

and ADD to the end of the file the share setting for your folder:

comment = ANY_COMMENT
read only = no
only guest=no
guest ok=no
create mask=0777
directory mask=0777

Where SHARE_FOLDER_NAME is the name you want to give to this share, ANY_COMMENT is just a comment, PATH_OF_THE_SHARED_FOLDER is the path of the folder to share (for ex. if I want to share my home folder it is: /home/stefano ).
To save just press CTRL+X and confirm with Y.

Setup a password

It’s time to setup a password for your user. Type:

$ sudo smbpasswd -a username

where username is your local username. Provide a new password.

Restart the server

To restart the server and make all change available, type:

$ sudo /etc/init.d/samba restart

Connect to your share

Now you can try to connect to your samba server.

For example: in Mac OS X you can press from a Finder window Command+k (+k). In the server address type smb://IP_ADDRESS_OF_YOUR_SERVER/SHARE_FOLDER_NAME and provide your Username and your Password that you previously created.