sudo apt-get update sudo apt-get install samba samba-common-bin sudo mkdir -m 1777 /data sudo mv /etc/samba/smb.conf /etc/samba/smb.conf/$(date +%F) sudo bash cd /etc/samba grep -ve ^# -ve ‘^;’ -ve ^$ smb.conf.2103-11-26 > smb.conf Now at a full root user prompt, and moving into the /etc/samba directory, we can filter the contents of the backup file back into the smb.conf. we can use grep for this. We want to remove the extra comments and blank lines from the file to make it easier to read. We use grep, other may oprefer to used the command sed. grep -ve ^# -ve ‘^;’ -ve ^$ smb.conf.2103-11-26 > smb.conf Understanding the GREP Filter The command may look a little messy but is really useful to us. -ve ^# : First we remove lines that start with a # -ve ‘^;’ : The we do the same for lines beginning with ; Note the quotes here as the ; has other meanings so we escape the semi-colon in the quotes -ve ^$ : Finally we remove empty lines > : This is used to redirect the output to the new smb.conf. We go from and incredible 333 lines in the original file to a minute 34 lines in the new file. This way, the result is quick and we have not lost out documentation as it is in the backup. We will now edit the /etc/samba/smb.conf and add a share definition for the /data directory. [data] comment = Data share path = /data browseable = yes read only = no testparm Creating samba users The last part of this tutorial will involve us creating samba users. These users must represent Linux users but their password can and should be different to the Linux password for security. This is not enforced, though. Using the command smbpasswd as the root user we can add new samba users. A user must have a password in samba to access shares. smbpasswd -a root smbpasswd -a pi The above commands add root and pi as samba users. By default, a TDB database is used to store this information. You can list current samba users with the command pdbedit. pdbedit -L Running the above command on my system lists the three users I have added as samba accounts. Testing the Connection with smbclient We can now simply test the process, even from Linux on our Pi. Using the command smbclient we can list shares on a server or even connect. smbclient -L localhost The command lists shares from the localhost. The Raspberry Pi Samba Server you are using. We could also use a Windows client and authenticate as one of the uses we have created. The video for this demonstration can be viewed on YouTube.