sharing

Create share points for 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:

   -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 smb.
                   By default a share point is enabled for the smb protocol.
                   001 Enable sharing for smb.
                   000 Turn off sharing of a share point altogether.

   -g guest_flag   Use this option to enable and disable guest access for smb.
                   By default guest access is enabled for smb.
                   001 Enable guest for smb.
                   000 Turn off guest access 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.

   -R 0/1          Make share read only for smb.
                   Specify 1 to enable read only. Specify 0 to disable read only.

   -E 0/1          Make share encrypted for smb v3 and later.
                   Specify 1 to enable encryption. Specify 0 to disable encryption.

   -f format       Only used when listing share points and only json format is supported.
              
For old versions of 'sharing' (pre-High Sierra) with afp and ftp.

   -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.

                   combine (binary AND) the following flags:
                   100 (enable sharing for afp), 
                   010 (enable sharing for smb), 
                   001 (enable sharing for ftp).

   -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.

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

The Apple File System (APFS) was introduced with macOS Sierra (10.12.4) in 2016. macOS will only fall back to afp when file sharing with Macs running previous versions of macOS or when working with Time Machine backups.

For Windows file sharing, Apple uses "SMBX" (Apples implementation of SMB) to support Microsoft’s SMB2. This is a proprietary Apple replacement for the open source Samba library. Early versions of SMBX had some compatibility problems when connecting to Windows servers.

Support for SMBX was added to Mac OS X Lion (10.7) in 2011.

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 SMB servies, also enable guest access.

$ sudo /usr/sbin/sharing -e ShareThisDirectory -S SP1 -g 001

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 macOS commands

Local man page: sharing - Command line help page on your local machine.
chmod - Change access permissions.
mount - Mount a file system.


 
Copyright © 1999-2025 windevcluster.com
Some rights reserved