Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 14.04 - Set Up A Public 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

Last updated: 11th January 2025
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch