Build a Samba file server
How to build your own file server using Samba and Ubuntu with help from Linux User & Developer veteran, Sukrit Dhandhania…
16 Read list
In the previous step we granted certain users write access to a share while allowing the rest read only access to it; we can also restrict the users who are allowed to read the contents of the shared directory. Modify the configuration of ‘usershare1’ and replace the parameter ‘read only’ with a new parameter – ‘read list’. Add the usernames of the users you want to allow to read. As you can see below, you can also continue to maintain a ‘write list’ alongside the ‘read list’. This kind of combination permits you to maintain a very fine-grained access control on your shares.
[usershare1] comment = Ubuntu File Server Share with Read/Write and Authentication path = /opt/usershare1 browsable = yes guest ok = no read list = hobbes write list = calvin tom jones
17 Granting permission to groups
When using the Linux server’s built-in user authentication system, Samba gains access to the UNIX groups maintained by the system. This means that you can grant or deny access to one or more groups, much like you granted access to certain users. To do that, add the users you want to grant access to a share to a certain group. For example, create a new UNIX group, ‘groupA’, and add some system users to it. Then open the Samba configure file and add the name of the group preceded by the ‘@’ symbol to the read or write list.
[usershare1] comment = Ubuntu File Server Share with Read/Write and Authentication path = /opt/usershare1 browsable = yes guest ok = no writeable = yes read list = hobbes write list = @groupA calvin tom jones
18 Test your configuration
Every time you make a configuration change to a working Samba setup and restart the server, you risk bringing the service down by introducing a bad configuration change. Samba ships with a tool called ‘testparm’ which allows you to test your configuration before you restart your server. Execute the tool by running the command ‘# testparm’ to begin the test. ‘testparm’ will go through the configuration of Samba and point out any errors. It will then display all the shares that are loaded by Samba. This tool can be a life-saver and it is a good idea to run it after making any changes to the configuration file.
19 Troubleshooting Samba
When you have an operational Samba server being used by several users, it can prove quite useful to have troubleshooting techniques up your sleeve for when things go wrong. The first place to look for info is in the Samba log files. These are usually stored under ‘/var/log/samba/’. Read the recent entries carefully to see what is wrong with the system. ‘testparm’, the tool we looked at in the previous step, can also be quite informative. Another useful tool is ‘smbstatus’, which we’ll look at next.















Hi, great article, very instructive.
And what about accessing the samba share from outside of the network ? Let’s say I’m at work and I would like to access my samba share wich is on my home network IP adress.
Any idear ?
Again great article :)
Cheers
Julien