Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 14.04 - Set Up A Samba Share

To install a public samba share in ubuntu, write this script to your ubuntu machine, edit the two settings files at the top, and run it as root (sudo su)

Even though the title states 14.04, this tutorial still applies for 16.04.

#!/bin/bash
# Author: Programster
# website: http://programster.blogspot.co.uk/


# Set the windows home group. On windows this defaults to WORKGROUP but you may
# have set up a custom home group name, in which case change it here.
HOME_GROUP="WORKGROUP"


# Define the folder that you want to make publicly shareable with everyone here.
# Please make sure to specify the FULL path (not relative)
PUBLIC_FOLDER='/var/www'

# Define who the owner and group should be 
# for any files that are created
USER="programster"
GROUP="www-data"

############################ END OF SETTINGS ###################################



sudo apt-get update
sudo apt-get install samba samba-common -y
sudo apt-get install python-glade2 system-config-samba -y

echo "[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no
force user = $USER
force group = $GROUP
guest account = $USER

[my_shared_folder]
public = yes
path = /code
browsable = yes
writable = yes
guest ok = yes
read only = no
create mask = 0755" | sudo tee /etc/samba/smb.conf

sudo service smbd restart
echo "Your SAMBA share is now set up."

Debugging

If you experience issues, you may find it useful to run the testparm command. This will tell you if there are any issues with your samba configuration.

References