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 ======================> 192.168.1.2
Ubuntu 16.10 machine IP Address =====================> 192.168.1.3
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.
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.
Then add the Ubuntu system entry as shown below.
192.168.1.3 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 ================================ [global] 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 ============================== [Public] 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.
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:
[Protected] 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.
You should be prompted for a username and password to access the Protected share.
- Students Tutorial – Samba Filesharing Between Windows 10 and Ubuntu 16.10
- How to Access Windows 10 Files from Ubuntu 17.04
- Sharing Windows 10 Shares with Ubuntu 17.04 via Samba
- Create a Public Samba Share on Ubuntu 17.04 / 17.10
- Create a Private Samba Share on Ubuntu 17.04 / 17.10
- Easily Share Ubuntu 17.10 Public Folder with Windows 10
- Quickly Enable File Sharing Between Windows 10 and Ubuntu 17.04 / 17.10
- Access User’s Home Folders via Samba on Ubuntu 17.04 / 17.10
- Share Files on Ubuntu 16.04 LTS with Windows 10 Systems