14.4 Sharing Files

14.4 Sharing Files

To export a directory to SMB clients (that is, to share a directory with a client), add a section like this to your smb.conf file, where label is what you would like to call the share, and path is the full directory path:

  path = path
  comment = share description
  guest ok = no
  writable = yes
  printable = no

These parameters are useful in directory shares:

  • guest ok Allows guest access to the share. The public parameter is a synonym.

  • writable A yes or true setting here marks the share as read-write. Do not allow guest access to a read-write share.

  • printable Specifies a printing share; this parameter must be set to no or false for a directory share.

  • veto files Prevents the export of any files that match the given patterns. You must enclose each pattern inside forward slashes (so that it looks like /pattern/). Here's an example that bars object files, as well as any file or directory named bin:

         veto files = /*.o/bin/

14.4.1 Home Directories

You can put a special section called [homes] in your smb.conf file if you want to export home directories to users. The section should look like this:

  comment = home directories
  browseable = no
  writable = yes

By default, Samba reads the logged-in user's /etc/passwd entry to determine the user's home directory for [homes]. However, if you don't want Samba to follow this behavior (that is, you want to keep the Windows home directories in a different place than the regular Linux home directories), you can use the %S substitution in a path parameter. Here is an example that switches a user's [homes] directory to /u/user:

  path = /u/%S

Samba substitutes the current username for the %S.