Check this Out!Visit our social network pages for recent updates!

Lesson 54 – Share Ubuntu 16.10 Files to Windows 10 via Samba

Samba is an opensource implementation of the SMB/CIFS services used to seamlessly share files between client computers. Windows systems and many other modern operating systems use it to share files and printers among themselves and others.

This brief tutorial shows you how to quickly do it. No messing around. Just get users of other systems to access Ubuntu shares.

To get started, you’ll first need to verify that both the Windows 10 and Ubuntu 16.10 machines are able to ping each other at least. That means both should be on the same subnet or able to route to each other.

When you’re ready, continue below:

Both machines are assigned IP addresses below:

Windows 10 machine IP Address ======================>
Ubuntu 16.10 machine IP Address =====================>
Local Workgroup for both  =========================> WORKGROUP

Step 1: Verify Windows 10 local Workgroup

First, verify what Workgroup the Windows 10 machines belongs to. To do that, run the commands below from the command prompts

net config workstation

And you should see something like the screen below.

windows computer workgroup

Step 2: Create Host Record for the Ubuntu system in Windows hosts file

Next, since most likely there won’t be a DNS system in place, create an entry in Windows local host file for the Ubuntu machine so you can reference it with its name.

To do that, open the command prompts as administrator and run the commands below to open the local host file.

notepad C:\\Windows\System32\drivers\etc\hosts

Then add the Ubuntu system entry as shown below.              ubuntu1610.localhost             ubuntu1016

Save your changes and you’re done.

Step 3: Install and Configure Samba on Ubuntu

Next, go and install Samba. To do that, run the commands below.

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

After installing Samba, create a backup of Samba default configuration file by running the commands below.

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

Then run the command below to create a new samba configuration file and insert the highlighted code block to create a share for everyone call Public

sudo nano /etc/samba/smb.conf

Add the code below into the file.

#============================ Global definition ================================
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
name resolve order = bcast host
dns proxy = no

#============================ Share Definitions ============================== 

path = /samba/public
browsable =yes
writable = yes
guest ok = yes
read only = no
force user = nobody

Save your change. As you see above, we set the Ubuntu machine up with a workgroup name to match that of the Windows machine. Then we setup a share definition for a public location for everyone with full access.

Step 3: Create the Share Location

Now the Samba configuration is done, create the public location you defined above. To do that, run the commands below:

sudo mkdir -p /samba/public

Then grant everyone full access to that location.

sudo chown -R nobody:nogroup /samba/public
sudo chmod -R 0775 /samba/public

Save your changes and restart Samba services.

sudo service smbd restart

Now go and access the location from Windows.  You may have to enable Windows 10 network discovery and enable file sharing to see the location.

ubuntu samba share

That’s how to create a public share via Samba on Ubuntu systems.

Step 4: Create a Private Share

You can also create private shares and only allow members of certain group to access the location with passwords. That can be accomplished using Samba share difinition code block below:

 path = /samba/protected
 valid users = @smbgroup
 guest ok = no
 writable = yes
 browsable = yes

Add the above code to Samba configuration under the share definition line. See the valid user group? Create a group with that name and add members to it. Only members of the defined group will access that share.

To create the group, run the commands below

sudo addgroup smbgroup

You can add members to the group by running the commands below

sudo adduser richard -G smbgroup

Because each member who needs access will have to type a password, run the commands below for each member to create a samba password database password. Members must type their username and the password to access the location.

sudo smbpasswd -a richard

Now the user richard has rights.

Step 6: Create the Private Folder

Now that the share has been defined, go and create the private location by running the commands below.

sudo mkdir -p /samba/protected

Now run the commands below to protect the location by allowing only the members of the smbgroup access.

cd /samba/
sudo chown -R root:smbgroup protected
sudo chmod -R 0770 protected

Restart Samba services and test the share from Windows.

samba windows shares

You should be prompted for a username and password to access the Protected share.




Leave a Reply