Centos 6/RHEL hiding folders and files in Samba

If you are using Samba for file sharing on a network, you may want to hide files and folders for a variety of reasons, this can be easily achieved in a few steps.

This assumes that you have Samba installed and configured

First, log in as root and simply open your current Samba configuration file
 
# vi /etc/samba/smb.conf

In the [global] section of the Samba configuration file, add the following line in order to hide all dot (.) files

hide dot files = yes

Having done this, you should now include the veto files option. To do this, add the following lines, customising the values shown to suit your setup.

veto files = /.*/foldername/filename.txt/filename.???/
delete veto files = yes

When done, save the file before restarting the Samba server

# service smb start && service nmb start

Samba is customisable and enables you to determine the type of network service you wish to provide.

The addition of a few small lines will not only hide .dot files, they will ensure that a full range of other files and directories are removed from view as dictated by your needs.

Labels: , ,