Linux Mint UserShares are undoubtedly simple to create, but how about ClassicShares (samba shares)?

There is a small difference between these two above mentioned. UserShares are shares created from the file manager such as caja or nemo, while ClassicShares are shares created by adding definitions to the samba smb.conf file either directly or using an application.

Years ago, when I first looked at Samba shares I had the opportunity to learn from an old friend how to set up Samba shares the easy way. What I mean by easy is not a GUI to point and click but rather the steps of a straight forward setup that aims at simple permissions, controlled access and have some flexibility in a standalone samba server without having to get deep into ACL and the such. Next, I’ll share one of the simplest way I learned it to help you with the basics. Note that this setup may not fit all environments and your needs may vary. I hope you find it useful.

Let’s assume that you want to have have few shares in your home network with different access and specific permissions for few users. For reference, we will be creating the following samba shares with the following permissions:

Share: All Users – This share will be accessible with read/write permissions for all authenticated users. Guests will be denied access
Share: Guest – This share will be accessible with read/write permissions by guests and authenticated users.
Share: Private 1 – This share will be available to just 1 authenticated user with read/write permissions. No other authenticated user can access the share.
Share: Private 2 – This share will be available to all authenticated users but only 1 user will have read/write permissions while everyone else will have read-only access. Specific users can be allowed write access as needed.
Share: Private 3  – This share will be accessible by just 2 authenticated users both with read/write permissions. No guests or other authenticated user will have access to the share.

We will use the following accounts for this tutorial:

ralphy (default user in Linux Mint)
yaima (service user – not allowed to login)
nicky (service user – not allowed to login)

Creating shared folders

You must decide the location of the shares at this point; whether you create it under /home/$USER/ or even in a complete separate drive does not make a difference. Just remember to use the correct path in the smbshares configuration. For this tutorial, I will be using a complete separate drive for my own shares.

sudo mkdir --mode 775 -p data/all-users data/private-share-1 data/private-share-2 data/private-share-3 data/guests
sudo chown -R root:sambashare data
sudo chmod -R g+s data


Creating users

Let’s now create the additional user accounts we will use to map samba users later on:

sudo useradd -d /dev/null -s /usr/sbin/nologin username
where username is the account name being created.
sudo useradd -d /dev/null -s /usr/sbin/nologin yaima
sudo useradd -d /dev/null -s /usr/sbin/nologin nicky


Configuring Samba

To configure samba, open Terminal and first backup the current samba configuration:

cd /etc/samba/
sudo service samba stop
sudo cp smb.conf smb.conf.backup


Now, edit smb.conf replacing everything in that file with the following configuration:

Note: Make sure to update the netbios name accordingly or samba won’t authenticate your users. My mint box name is vm-mint-mate.

sudo vi /etc/samba/smb.conf

workgroup = WORKGROUP
log file = /var/log/samba/log.%m
syslog = 0
panic action = /usr/share/samba/panic-action %d
server role = standalone server
server string = Mint File Server
netbios name = vm-mint-mate
dns proxy = no
local master = yes
security = user
encrypt passwords = yes
usershare allow guests = yes
map to guest = bad user
guest account = nobody
name resolve order = bcast host
include = /etc/samba/smbshares.conf
force user = root
force group = sambashare

samba smb-conf

If you pay close attention to the configuration above, there is a reference to include /etc/samba/smbshares.conf. This file does not exist by default so we will create it next.  What we are doing is separating samba global configuration from our shares configuration to keep it organized:


sudo touch /etc/samba/smbshares.conf

The next step is to map samba users to the users we created above, as well as setting samba accounts password for those users… in Terminal:

sudo vi /etc/samba/smbusers
# Unix_name = SMB_Name1 SMB_Name2 ...
root = administrator
nobody = guest smbguest pcguest everyone
ralphy = ralphy
yaima= yaima
nicky = nicky


… and now let’s add the samba account password for these users:

sudo smbpasswd -a ralphy
sudo smbpasswd -a yaima
sudo smbpasswd -a nicky


Configuring Shares

Finally, let’s add our desired shares to /etc/samba/smbshares.conf. Make sure to replace /media/disk1/data with the correct path to your own created folders; also, replace users with your own.

sudo vi /etc/samba/smbshares.conf

[Private 1]
comment = Private Share 1
path = /media/disk1/data/private-share-1
browsable = yes
guest ok = no
read only = yes
write list = ralphy
available = yes
valid users = ralphy
create mask = 0760
directory mask = 0760
force user = root
public = no

[Private 2] comment = Private Share 2 path = /media/disk1/data/private-share-2 browsable = yes guest ok = no read list = @sambashare write list = ralphy available = yes create mask = 0760 directory mask = 0760 force user = root public = no

[Private 3] comment = Private Share 3 path = /media/disk1/data/private-share-3 browsable = yes guest ok = no read only = yes write list = ralphy yaima available = yes valid users = ralphy yaima create mask = 0760 directory mask = 0760 force user = root public = no

[All Users] comment = All Users Share path = /media/disk1/data/all-users browsable = yes guest ok = no writeable = yes available = yes create mask = 0760 directory mask = 0760 force user = root public = no

[Guests] comment = Guests Share path = /media/disk1/data/guests browsable = yes guest ok = yes read only = no writeable = yes available = yes create mask = 0776 directory mask = 0766 force user = root public = yes

Time to check the configuration for errors; from Terminal:

testparm /etc/samba/smb.conf


… and start samba once again!

sudo service samba start

You should be up and running at this point. Time to browse your shares and from other computers and verify all permissions are working as mentioned at the beginning of this tutorial.


Testing Samba shares from the network

This is the fun part since the hard work has been done already. First, I’m going to use a Windows client machine to test guests permissions.

Client: Windows 10
Account: guest

From a network machine, browse to \\your-mint-pc or \\x.x.x.x where x = IP address of your mint machine, and you should see all available shares in that host at this point.

The shares should have the following permissions:

All Users (no access)
Guests (read/write permissions)
Private Folder 1 (no access)
Private Folder 2 (no access)
Private Folder 3 (no access)


If you are asked for a username and password instead of being presented with all the available shares by default, use guest as username without password and hit OK to login.



Now, let’s test user yaima and verify the following permissions:

All Users (read/write permissions)
Guests (read/write permissions)
Private Folder 1 (no access)
Private Folder 2 (read-only permissions)
Private Folder 3 (read/write permissions)

Client: Windows 10
Account: yaima

network share login
All Users share read/write permissions
guest share read/write permissions
Guests share read/write permissions
Private 1 share no access
Private 1 share no access
Private 2 share read-only access
Private 2 share read-only access
Private 3 share read/write access
Private 3 share read/write access

Test the other accounts from multiple clients in that same way. Let me know how it works for you in the comments!

Related Post

File Sharing in Linux Mint 17.x Want to share files in Linux Mint? The process is rather simple. If basic sharing is what you're after in Linux Mint, share your files and setup folde...