sharing

Create share points for afp (Apple Filing Protocol), ftp and Microsoft smb services.

Syntax
      sharing [-a path [options]] [-e share_point_name [options]]
              [-r share_point_name] [-l]

Key
   -a path              Add a new share point for the directory specified by path.
   -e share_point_name  Edit the share point record specified by share_point_name.
   -r share_point_name  Delete the share point record specified by share_point_name.
   -l                   List all existing share point records.

 The following options modify share point record attributes:
   -A afp_name     Use customized name afp_name when using share point with afp.
   -F ftp_name     Use customized name ftp_name when using share point with ftp.
   -S smb_name     Use customized name smb_name when using share points with smb.

   -s flags        Use this option to enable and disable sharing via afp, ftp, and smb.
                   By default a share point is enabled for afp, ftp, and smb protocols.

                   To enable/disable particular services, combine (binary AND) the following flags:
                   100 (enable sharing for afp), 
                   010 (enable sharing for smb), 
                   001 (enable sharing for ftp). Specify 000 to turn off sharing of a share point altogether.
                   Use a customized name smb_name if appropriate when using share points with smb.

   -g guest_flag   Use this option to enable and disable guest access for afp, ftp, and smb.
                   By default guest access is enabled for afp, ftp, and smb.
                   To enable/disable guest access to particular services, combine (binary AND) the following flags:
                   100  (enable guest for afp),
                   010 (enable guest for smb), 
                   001 (enable guest for ftp). Specify 000 to turn off guest access for a share point altogether.

   -i inherit_privileges_flag
                   Use this option to enable/disable the "inherit privileges" attribute for afp, ftp, and smb.
                   By default "inherit privileges" is enabled for ftp only.

                   To enable/disable guest access to particular services, combine (binary AND) the following flags:
                   100 ("inherit privileges" for afp),
                   010 ("inherit privileges" for smb), 
                   001 ("inherit privileges" for ftp).  Specify 000 to turn off "inherit privileges" for a share point altogether.

   -n customized_record_name
                   Specify a customized_record_name to be used as the share point record name.
                   By default the record name is the name of the directory pointed to by the share point record.
                   This directory is specified by the path when the record is created.

The GUI controls for sharing can be found under System Preferences > Sharing > File Sharing

For Windows file sharing, Apple uses "SMBX" to support Microsoft's SMB2. This is a proprietary Apple replacement for the open source Samba library.

In OS X Mavericks, Apple began migrating from afp to SMBX, macOS will only fall back to afp when file sharing with Macs running previous versions of macOS or when working with Time Machine backups.

Location of tool: usr/sbin/sharing

Examples

Create a share point for the directory "/SomePath/ShareThisDirectory":

$ sudo /usr/sbin/sharing -a /SomePath/ShareThisDirectory

Edit the share point record created above, and add a customized name "SP1" for afp servies, also enable guest access only for afp and smb.

$ sudo /usr/sbin/sharing -e ShareThisDirectory -A SP1 -g 101

To turn off guest access to the newly-created share:

$ sudo /usr/sbin/sharing -e ShareThisDirectory -g 000

Remove the share entirely:

$ sudo /usr/sbin/sharing -r ShareThisDirectory

“Plenty of people miss their share of happiness, not because they never found it, but because they didn't stop to enjoy it.” ~ William Feather

Related:

chmod - Change access permissions
mount - Mount a file system


Copyright © SS64.com 1999-2017
Some rights reserved